
I want to combine three queries using union.
1.SELECT * from user_projects where status='O' order by id desc
It returns the following ids
115,112,111,106,5,4,3
Second query
2.select * from userprojects where status!='F' and status!='D' and status!='O' and newproject='yes' order by id desc
It returns the following ids
114,113,105,104,103,102,101,100,99
3.select * from userprojects where status!='F' and status!='D' and status!='O' and newproject='no'
It returns the following ids
110,109,108,107,98,97,96
But i am combine the three queries using union
(SELECT * from userprojects where status='O' order by id desc) union all (select * from userprojects where status!='F' and status!='D' and status!='O' and newproject='yes' order by id desc ) union all (select * from userprojects where status!='F' and status!='D' and status!='O' and new_project='no' order by id desc)
it return
3,4,5,106,111,112,115,99,100,......96,97...................
But i want
115,112,111,106,5,4,3,114,113,105,104,103,.........110,109,108........
Please any one help me
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.