Ok, I have a query right now that pulls all the events out of a table. It works great. However, I want to add one condition to the query... my setup is as follows:
1. The first table (events) contains the events and their data. It consists of: eventID, eventTitle, eventDateTime, etc.
2. The second table (events_to_categories) contains: eventID and categoryID. This table just links the events to the categories they belong to. One event can belong to multiple categories (leading to multiple rows in this table with the same eventID).
My original query is as follows:
I would like to be able to narrow down my results from all events returned to only events with specific categories (assigned to them in the second table). For example, to pull all events assigned to the category id of 1. Or even multiple categories, such as events that are in category 1 or 2... just not all events. How would I go about doing this? For more background on this, here is the original thread (but I figured it was mostly solved and deemed this a separate question): https://forums.macrumors.com/threads/1136892/
Thanks in advance!
Brendon
1. The first table (events) contains the events and their data. It consists of: eventID, eventTitle, eventDateTime, etc.
2. The second table (events_to_categories) contains: eventID and categoryID. This table just links the events to the categories they belong to. One event can belong to multiple categories (leading to multiple rows in this table with the same eventID).
My original query is as follows:
Code:
SELECT YEAR(`eventDateTime`) as `year`, MONTH(`eventDateTime`) as `month`, DAY(`eventDateTime`) as `day`, `eventID`, `eventDateTime`, `eventTitle`, `eventDescRaw` FROM `events` ORDER BY `year`, `month`, `day` ASC
I would like to be able to narrow down my results from all events returned to only events with specific categories (assigned to them in the second table). For example, to pull all events assigned to the category id of 1. Or even multiple categories, such as events that are in category 1 or 2... just not all events. How would I go about doing this? For more background on this, here is the original thread (but I figured it was mostly solved and deemed this a separate question): https://forums.macrumors.com/threads/1136892/
Thanks in advance!
Brendon
Last edited: