I have two tables, one that stores specific date report periods, and another that tracks events associated with those periods.
The MySQL tables are:
When EVENT records are created, a corresponding report_id is stored in the EVENT table for each record. There can be any number of events created that tie back to one or more REPORT periods. What I want to be able to do is run a query on REPORT and use the results to query all the associated rows in the EVENTS table. Again, I'm using MySQL v3.23.
When I do a query on REPORT for, say, 'January 2004' it returns four records with report_ids numbered 1, 2, 3 and 4. From here I want to query the EVENT table using the four found report_ids ... something akin to ...
I'm something of a neophyte at this, and this isn't hard to do when we're talking about finding a one-to-one match, but I'm not sure how to write the query when the values that need to be queried are more than one.
I'm wondering if ListFind() will help me out of the woods here. I hope this makes sense. Any help is appreciated.
The MySQL tables are:
Code:
REPORT
report_id INT(8) PK
period VARCHAR(25)
EVENT
event_id INT(8) PK
report_id INT(8)
event LONGTEXT
When EVENT records are created, a corresponding report_id is stored in the EVENT table for each record. There can be any number of events created that tie back to one or more REPORT periods. What I want to be able to do is run a query on REPORT and use the results to query all the associated rows in the EVENTS table. Again, I'm using MySQL v3.23.
When I do a query on REPORT for, say, 'January 2004' it returns four records with report_ids numbered 1, 2, 3 and 4. From here I want to query the EVENT table using the four found report_ids ... something akin to ...
Code:
SELECT report_id
FROM events
WHERE report_id = ANY RECORD IN EVENTS WITH THE SAME
REPORT_IDs AS THAT FOUND IN THE
REPORT TABLE.
I'm something of a neophyte at this, and this isn't hard to do when we're talking about finding a one-to-one match, but I'm not sure how to write the query when the values that need to be queried are more than one.
I'm wondering if ListFind() will help me out of the woods here. I hope this makes sense. Any help is appreciated.