Subject | Re: [ib-support] How to join results of two queries. |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-01-06T07:45:51Z |
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.
Set
- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.FirebirdSQL.org/Foundation
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' asHTH,
>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
Set
- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.FirebirdSQL.org/Foundation