Skip to content
Advertisement

SQL – Compare 2 tables and show non existent data

Ok, I have 2 tables that I need to do a comparison to. The idea is to show anyone in the database who has not purchased a specific product.

Table 1

Table 2

What I am wanting to come back is

So, I am stuck at figuring out the code as I don’t have an ID match between the tables, only the Product name match. I know this is easy but I am drawing a blank right now.

Also, sorry for the poor formatting

Jayson

Advertisement

Answer

General all possible combinations using cross join and filter out the ones that exist:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement