(Using MySQL and PHP)

I need to only return a row from table1 if its id is not found in table2.
The query below is how I think it should work. However (as I had imagined),
this doesn't work. Syntax error (you can't put a select inside a select like

SELECT table1.id FROM table1 WHERE table1.sold=1 AND table1.id NOT IN
(SELECT table2.table1_id FROM table2)

(and no, those aren't the real table or field names - just trying to be

I could do a SELECT first that gets all the values in the table2, then (in
PHP) run through a result set of rows from table1, checking each time to see
if its id is in table2, and if it isn't, display it...but this seems

I went through all of the functions to use in a WHERE clause in my MySQL
book...am I missing something?

Katie Evans-Young
Web Developer
Evans-Young Designs
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.445 / Virus Database: 250 - Release Date: 1/21/2003

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

Reply via email to