Joseph Chambers
Joseph Chambers

Reputation: 4068

How to compare rows in 2 different tables: mySQL - what's different

SELECT pid,cid,product_id,thickness FROM products WHERE thickness <> "";
SELECT cid,level,thickness FROM catalog WHERE thickness <> "";

All pid are mapped to the cid. I'm only interested in level 2 mapping.

Goal, I want to know which products DO NOT have the same value in thickness in both catalog, products. Note, products are attached to a category via cid and all products are attached to level 2 categories.

Upvotes: 1

Views: 59

Answers (1)

John Woo
John Woo

Reputation: 263693

SELECT  a.pid, a.product_ID
FROM    products a
        INNER JOIN catalog b
            ON  a.cid = b.cid AND
                b.level = 2
WHERE   a.thickness <> b.thickess

Upvotes: 1

Related Questions