Assign query results to MySQL variable

Posted by 5un5 on Stack Overflow See other posts from Stack Overflow or by 5un5
Published on 2012-12-06T05:00:31Z Indexed on 2012/12/06 5:03 UTC
Read the original article Hit count: 144

Filed under:
|
|

I'm querying a big mysql database with only read privileges, and I'd like to set some slow query results to a variable, 'foo', so I can use them again in other queries.

I get, ERROR 1193 (HY000): Unknown system variable '$foo' when I enter:

set $foo := (select *
            from table1 join table2 
            where bar = 0 
            group by id);

Is there a way to do this with variables, since I don't have privileges to create temporary tables?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about variables