[thelist] SQL selecting distinct from multiple index tables

Joshua Olson joshua at waetech.com
Fri Jan 30 23:54:45 CST 2004


-----Original Message-----
Sent: Saturday, January 31, 2004 12:24 AM
Subject: [thelist] SQL selecting distinct from multiple index tables

> Any suggestions on how to combine this into a single query?

David,

If those two queries are returning the data you want, then combining them is
straightforward:

select distinct Organizations.OID , Organizations.Name ,
Organizations.Acronym
from OrgDocs , Organizations
where OrgDocs.OrgID = Organizations.OID
UNION
select distinct Organizations.OID , Organizations.Name ,
Organizations.Acronym
from OrgProjects , Organizations
where OrgProjects.OrgID = Organizations.OID

The only addition is that I added the UNION operator between the two
queries.  UNION automatically discards duplicate rows.

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/GA/
706.210.0168




More information about the thelist mailing list