Re: the opposite of a join?

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

 



2007. 10. 3, szerda keltezéssel 05.21-kor jd.pillion@xxxxxxxxx ezt írta:
> 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?
> 

maybe something like

SELECT * FROM company WHERE (SELECT COUNT(*) FROM contact WHERE
company_id = company.company_id)=0

it's not very efficient, but I don't have any better idea. someone else?

greets
Zoltán Németh

>  
> 
> Thanks
> 
>  
> 
> J
> 
>  
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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