[thelist] MySQL how to table1.id not in table2.whatever
rudy
r937 at interlog.com
Tue Feb 18 16:16:01 CST 2003
> I'd like to see which products are "orphans" and
> aren't listed in pro_gal_tbl.product_id
select product_tbl.id
, product_tbl.name
from product_tbl
left outer
join pro_gal_tbl
on product_tbl.id
= pro_gal_tbl.product_id
where pro_gal_tbl.product_id is null
this is a left join, which by itself returns both matched and unmatched rows
from the left table, and then checking for null in the unmatched column
gives you the orphans
> Also, any recommended overviews of JOINS and what have you?
http://www.w3schools.com/sql/sql_join.asp
rudy
More information about the thelist
mailing list