Subject | How to join results of two queries. |
---|---|
Author | Neil Murby |
Post date | 2003-01-06T04:09:21Z |
Hi,
In my application I have clients and staff, both on the same mailing
list.
I select the staff like this:
select staff.staffid as id, staff.lastname as name, 'staff' as
recordtype
from staff right join liststaff on staff.staffid = liststaff.staffid
where liststaff.ListID = :ListID
and I select the contacts in a similar fashion
select contact.contactid as id, contact.lastname as name, 'contact' as
recordtype
from contact right join listcontacts on contact.contactid =
listcontacts.contactid
where listcontacts.ListID = :ListID
What I'd like to be able to do is somehow create a query like this:
select recordtype, id, name
from <staff query> full join <contact query>
order by name
I haven't been able to figure out a way to do this, is there one?
Any help would be greatly appreciated.
Thanks,
Neil.
BTW I'm using IB 6.5 on Linux (RH 8.0)
IMPORTANT -
(1) The contents of this e.mail and its attachments are confidential and privileged. Any unauthorised use of the contents is expressly prohibited. If you receive this e.mail in error, please contact us, then delete the e.mail.
(2) Before opening or using attachments, check them for viruses and defects. The contents of this e.mail and its attachments may become scrambled, truncated or altered in transmission. Please notify us of any anomalies.
(3) Our liability is limited to resupplying the e.mail and attached files or the cost of having them resupplied.
(4) Minter Ellison collects personal information to provide and market our services. For more information about use, disclosure and access see our privacy policy at www.minterellison.com.
In my application I have clients and staff, both on the same mailing
list.
I select the staff like this:
select staff.staffid as id, staff.lastname as name, 'staff' as
recordtype
from staff right join liststaff on staff.staffid = liststaff.staffid
where liststaff.ListID = :ListID
and I select the contacts in a similar fashion
select contact.contactid as id, contact.lastname as name, 'contact' as
recordtype
from contact right join listcontacts on contact.contactid =
listcontacts.contactid
where listcontacts.ListID = :ListID
What I'd like to be able to do is somehow create a query like this:
select recordtype, id, name
from <staff query> full join <contact query>
order by name
I haven't been able to figure out a way to do this, is there one?
Any help would be greatly appreciated.
Thanks,
Neil.
BTW I'm using IB 6.5 on Linux (RH 8.0)
IMPORTANT -
(1) The contents of this e.mail and its attachments are confidential and privileged. Any unauthorised use of the contents is expressly prohibited. If you receive this e.mail in error, please contact us, then delete the e.mail.
(2) Before opening or using attachments, check them for viruses and defects. The contents of this e.mail and its attachments may become scrambled, truncated or altered in transmission. Please notify us of any anomalies.
(3) Our liability is limited to resupplying the e.mail and attached files or the cost of having them resupplied.
(4) Minter Ellison collects personal information to provide and market our services. For more information about use, disclosure and access see our privacy policy at www.minterellison.com.