Combine two mysql queries with two different order by statements -
i want combine these 2 queries.
select * table1 status='pending' , adr='' order id desc limit 0,1; select * table1 status='pending' , adr='new' order rand() limit 1
you can use union set operator concatenate results of 2 queries
( select * table1 status='pending' , adr='' order id desc limit 1 ) union ( select * table1 status='pending' , adr='new' order rand() limit 1 )
reference: union all https://dev.mysql.com/doc/refman/5.5/en/union.html
Comments
Post a Comment