I have a user
table and an item
table where I can assign multiple items to each user. I need a simple query, that will select all users who don't have assigned items with certain type.
The problem with my query is that if some user have assigned multiple items, let's say 100, 200 and 300, they will still be selected, because they have assigned items with types 100 and 200. What I want is to completly exclude all users who have assigned item 300, regardless from any other items they may have assigned.
I found similar question with answers but it deals with a different relation type (MtM) and I have a problem with translating answers to my particular case.
My incomplete query that needs expanding
SELECT * FROM user
LEFT JOIN item
ON user.id = item.assigned_to_id
WHERE item.id is null OR item.type != 300
Properly working query but with a subquery, which I would like to avoid
SELECT * FROM user
WHERE user.id NOT IN
(
SELECT i.assigned_to_id
FROM item i
WHERE i.type = 300
AND i.assigned_to_id is not null
)