I am trying to join 2 tables and filter on a value not being present.
Table_Items: item_id, title, etc
Table_History: item_id, history_id, action, date
For each disc there are many possible actions (purchased,added,played,ripped,etc) each action creates a new row in table_history linked by item_id. The query I am looking for will return all discs which have not been ripped. My query returns too many rows, everything is returned because there is at least one entry in the history table for each item.
SELECT items.item_id, items.title AS Title, items.`author/creator`, history.action
FROM items
LEFT JOIN history ON items.item_id = history.item_id
WHERE history.action NOT LIKE 'Ripped%' GROUP BY items.item_id ORDER BY title
I am using mySQL. Help would be appreciated! Thank you.
Just add the action filter to the join and then test for null (anti-join) in the where
you could also do a not in