Right, I have 3 tables, "events" , "events_per_news_item" , and 'news_items'
I want a list of all events, with an extra column with some indicator if it's active for a specified news_item (this will be for creating a multi-select list).
e.g.
The query I've come up with only returns the rows with a match in events_per_news_item, but I need a list of every event. The selected column doesn't have to be yes or no, it can just be the news_item_id or null.
I want a list of all events, with an extra column with some indicator if it's active for a specified news_item (this will be for creating a multi-select list).
e.g.
Code:
event_id | name | selected
--------------------------------------
1001 | bjork | no
3848 | beck | no
3494 | arctic monkeys | yes
8214 | css | no
The query I've come up with only returns the rows with a match in events_per_news_item, but I need a list of every event. The selected column doesn't have to be yes or no, it can just be the news_item_id or null.
Code:
SELECT
events.event_id,
events.name,
events_per_news_item.news_item_id AS selected
FROM
events
LEFT JOIN events_per_news_item ON events.event_id = events_per_news_item.event_id
WHERE
events_per_news_item.news_item_id = 8