Liam Delahunty: Home Tips Web Contact
Recommended laptop
under £500
.

Think I deserve a present? See my Amazon Wish List

MySQL Left Outer Join

I want to see how many products don't have an image. The products are all in the product_tbl, and the images in the image_tbl. The image table caontains a column product_id.

SELECT product_tbl.id, product_tbl.product_code, product_tbl.product_name
FROM product_tbl
LEFT OUTER JOIN image_tbl
ON product_tbl.id = image_tbl.product_id
WHERE image_tbl.product_id IS NULL

This will give me a list off all the products that are in product_tbl but don't have an entry in image_tbl.

Share this!