[thelist] MySQL how to table1.id not in table2.whatever

Liam Delahunty ldelahunty at britstream.com
Tue Feb 18 15:54:01 CST 2003


I have a table product_tbl and a table to associate the products with the
galleries pro_gal_tbl. I'd like to see which products are "orphans" and
aren't listed in pro_gal_tbl.product_id

A simple query like so,
SELECT product_tbl.id, product_tbl.name, pro_gal_tbl.name
FROM product_tbl, pro_gal_tbl
WHERE product_tbl.id != pro_gal_tbl.product_id

gives me all rows, I just want to find the product_tbl.id that aren't in
pro_gal_tbl.product_id

I'm using PHP/MySQL, I'm sure I've done this before but it's 21:45 here and
I'm knackered...

Also, any recommended overviews of JOINS and what have you? I've read so
much my head is spinning.

Kind regards, Liam Delahunty, Mega Products Limited
http://www.megaproducts.co.uk/ web design, programming, e-commerce
http://www.onlinesales.co.uk/ Open Source PHP/MySQL E-commerce App.
http://www.britstream.com/ Hosting/ Domain Names From UKP 7.50 p.a.




More information about the thelist mailing list