Re: the opposite of a join?
| From: | Martin Marques | Date: | Wed, 03 Oct 2007 19:16:02 +0000 |
| Subject: | Re: the opposite of a join? | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-44122@lists.php.net to get a copy of this message | ||
jd.pillion@gmail.com 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 * FROM company WHERE id NOT IN (SELECT companyID FROM contacts); -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 --------------------------------------------------------- Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática | '@' || 'unl.edu.ar'; Universidad Nacional | DBA, Programador, del Litoral | Administrador ---------------------------------------------------------