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
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 =
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
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
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
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.*)