I have a union query which is formed from 2 other queries to join 2 similar tables into 1.
The first query takes the rows from table1 where a certain item in the table is equal to x.
It doesn't really matter what the 2nd query does other than it uses a different table, table2..
I join the 2 tables together and when presented to the user the rows from the 1st able are show first and the from the second table after. This is exactly what I want!
However I would like to sort the first table into some order and then apply the same to the second table.
I thought this would be as easy as putting an ORDER BY on each of the component select statements. This has the effect of sorting the entire union. If I only put the order by on the first select nothing is sorted and if I put it on the 2nd select the whole union is sorted.
Is there any way to have table 1 sorted by x followed by table 2 sorted by x?
The first query takes the rows from table1 where a certain item in the table is equal to x.
It doesn't really matter what the 2nd query does other than it uses a different table, table2..
I join the 2 tables together and when presented to the user the rows from the 1st able are show first and the from the second table after. This is exactly what I want!
However I would like to sort the first table into some order and then apply the same to the second table.
I thought this would be as easy as putting an ORDER BY on each of the component select statements. This has the effect of sorting the entire union. If I only put the order by on the first select nothing is sorted and if I put it on the 2nd select the whole union is sorted.
Is there any way to have table 1 sorted by x followed by table 2 sorted by x?