Subject Re: [ib-support] How to join results of two queries.
Author Svein Erling Tysvaer
Neil,
as Hans wrote, use a union. Also, remove RIGHT from your queries unless you
have only shown us a subset of your queries. You want an inner join and
using RIGHT (or LEFT) changes it to an outer join.

>select staff.staffid as id, staff.lastname as name, 'staff' as
>recordtype
>from staff join liststaff on staff.staffid = liststaff.staffid
>where liststaff.ListID = :ListID
>union
>select contact.contactid as id, contact.lastname as name, 'contact' as
>recordtype
>from contact join listcontacts on contact.contactid =
>listcontacts.contactid
>where listcontacts.ListID = :ListID
>order by 2

HTH,

Set

- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.FirebirdSQL.org/Foundation