Re: [vox-tech] SQL selecting distinct from multiple index tables

2004-01-31 Thread Foo Lim
select distinct Organizations.OID, Organizations.Name, Organizations.Acronym from Organizations o where o.OID in (select OrgID from OrgDocs union select OrgID from OrgProjects); Build subqueries first, thereby avoiding the full table joins. On Fri, 30 Jan 2004, David Siedband wrote: I

Re: [vox-tech] SQL selecting distinct from multiple index tables (solution)

2004-01-31 Thread Ted Deppner
On Fri, Jan 30, 2004 at 10:04:35PM -0800, David Siedband wrote: ahh, I just got this to work. Here's the query I used (MySQL 3.x) select distinct Organizations.OID , Organizations.Name , Organizations.Acronym from OrgDocs , OrgProjects , Organizations where (OrgDocs.OrgID =

[vox-tech] SQL selecting distinct from multiple index tables

2004-01-30 Thread David Siedband
I have two index tables the associate Organizations with documents and projects. I'm trying to write a query that returns all the organizations that are associated with either a project or document. To select distinct organization that are either associated with a Document or a Project, I'm

Re: [vox-tech] SQL selecting distinct from multiple index tables

2004-01-30 Thread Mitch Patenaude
select distinct O.OID, O.Name, O.Acronym from Organizations O, OrgDocs D, OrgProjects P where D.OrgID = O.OID or P.OrgID = O.OID I think this will result in two full table scans though.. -- Mitch On Friday, Jan 30, 2004, at 21:24 US/Pacific, David Siedband wrote: I have two index

Re: [vox-tech] SQL selecting distinct from multiple index tables (solution)

2004-01-30 Thread David Siedband
ahh, I just got this to work. Here's the query I used (MySQL 3.x) select distinct Organizations.OID , Organizations.Name , Organizations.Acronym from OrgDocs , OrgProjects , Organizations where (OrgDocs.OrgID = Organizations.OID) or (OrgProjects.OrgID = Organizations.OID) still interested in

Re: [vox-tech] SQL selecting distinct from multiple index tables

2004-01-30 Thread Jeff Newmiller
On Fri, 30 Jan 2004, Mitch Patenaude wrote: select distinct O.OID, O.Name, O.Acronym from Organizations O, OrgDocs D, OrgProjects P where D.OrgID = O.OID or P.OrgID = O.OID I think this will result in two full table scans though.. Actually, it will probably result in Count(P.*)