Skip to content
Advertisement

How to return values where one value is in both tables but another is in only one?

I have two tables, which look roughly like this:

I want to query these tables to return only the customers who are in both tables, but also to only return the rows where that combination of customer & offer does not exist in table2.

In other words, the results should look like this:

Does anyone know how best to do this please?

Advertisement

Answer

This sounds like exists and not exists:

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