结合多个查询

时间:2011-02-11 13:00:46

标签: php mysql

我想做这样的事情:

set @col = 'test'; select @col;

并在mysql_query PHP函数中使用。我该怎么做才能返回'test'(第二次查询的结果)?

3 个答案:

答案 0 :(得分:0)

mysql_query不支持多个查询。您需要使用Mysqli函数。

答案 1 :(得分:0)

你可以将两个组合成一个像

select if (@col is null, @col:='test', @col);

答案 2 :(得分:0)

select a,b,c,d from table1 where a=2

union all

select a,b,c,d from table1 where a=3;