Skip to content
Advertisement

get users that did not buy a product

I have three tables

users table

products table

users_buy table

I want to get users who did not buy a specific product

for example, user number 20 bought 5 product with ids [1,2,3,4,5] and user number 19 bought 3 product with ids [1,2,3]

And user number 18 bought 2 product with ids [1,3]

I want to get users who did not buy any product with the id 5

ie I want user 18 and 19

How can I do this?

Advertisement

Answer

This will list of all users that did not buy product id 5:

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