I want to do something like this:
set @col = 'test'; select @col;
And use in the mysql_query
PHP function. How can I do that so it should return 'test' (resul开发者_开发百科t of second query)?
mysql_query doesn't support multiple queries. You need to use the Mysqli functions for that.
select a,b,c,d from table1 where a=2
union all
select a,b,c,d from table1 where a=3;
you can combine two become one like
select if (@col is null, @col:='test', @col);
精彩评论