Without actually giving all the details of my query: Is there a way of joing the results of two separate queries on different tables? for example if i had a table
re
Completing @Microgen's answer... Since you already have your two first select working as you want, you can keep those results in temporary tables:
create temporary table tmp1 as ;
alter table tmp1 add ;
create temporary table tmp2 as ;
alter table tmp2 add ;
Then, you could apply a simple join to get your final result:
select tmp1.id, tmp1.name, tmp1.address, tmp2.occupation
from tmp1 inner join tmp2 using (id)
order by tmp1.id;
Another way to do it is to use VIEW
, but since the indexing is not the best thing they have, I would avoid them, specially when your first two select
are as complex.