This was a strange case where I had to select all the items that were NOT assigned to a user. The data structure assumes that there is a 1 to 1 relationship between a user and an item. This is a simplified version of the query, but it's one of those queries that takes a while to figure out.
- SELECT item.id, item.name FROM items LEFT OUTER JOIN users ON users.item_id = items.id WHERE users.item_id IS NULL
You need to login to post a comment.