[thelist] SQL selecting distinct from multiple index tables

Raditha Dissanayake jabber at raditha.com
Fri Jan 30 23:55:57 CST 2004


Hi
can't say for certain without knowing more about your data but i would 
try something like
where ( OrgDocs.OrgID = Organizations.OID ) OR  (OrgProjects.OrgID = 
Organizations.OID)

and add the other columns to your select.

all the best

David Siedband wrote:

> 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 unique organizations that are either associated with a 
> Document or a Project, I'm using SQL that looks like this.
>
> select distinct Organizations.OID , Organizations.Name , 
> Organizations.Acronym
> from OrgDocs , Organizations
> where OrgDocs.OrgID = Organizations.OID
>
> select distinct Organizations.OID , Organizations.Name , 
> Organizations.Acronym
> from OrgProjects , Organizations
> where OrgProjects.OrgID = Organizations.OID
>
> Any suggestions on how to combine this into a single query?
>
> thx,
>
> -- 
> David
>
>
>
>
>


-- 
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.




More information about the thelist mailing list