Re: the opposite of a join?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/3/07, jd.pillion@xxxxxxxxx <jd.pillion@xxxxxxxxx> wrote:
>
> I have a company table and a contacts table.  In the contacts table, there
> is a field called "companyID" which is a link to a row in the company
> table.
>
>
>
> What is the easiest way to query the company table for all the company
> rows
> whose ID is NOT linked to in the contact table? Basically, the opposite of
> a
> join?



SELECT company.*
FROM company LEFT JOIN contacts ON (company.companyID = contacts.companyID)
WHERE contacts.companyID IS NULL

(Assuming your DB can handle a left join)

-James



Thanks
>
>
>
> J
>
>
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux