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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -