Return to Snippet

Revision: 35732
at November 12, 2010 10:31 by Jamie


Initial Code
SELECT item.id, item.name FROM items LEFT OUTER JOIN users ON users.item_id = items.id where users.item_id is null

Initial URL

                                

Initial Description
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.

Initial Title
MySQL Join on NOT Condition

Initial Tags

                                

Initial Language
MySQL