I'm wondering how to run a query using the results of a previous query. I have a page that queries a table on a date range specified by the user and passed to the page via URL variables (see below).
The IDs for the records that fall within this range are captured in this query (e.g., report_ids 142, 153, 179 and 180 are found in this query).
What I'd like to do is place the results of that query (142, 153, 179, and 180) and put them in the WHERE clause of another query to find all the records in another table that match those IDs. Do I need to incorporate a CFLOOP in the query? How would I do this?
Code:
<cfparam name="start_date" default="URL.start_date">
<cfparam name="end_date" default="URL.end_date">
<CFQUERY DATASOURCE="#REQUEST.DataSource#" name="GetMonthList">
SELECT report_id, t_date
FROM report
WHERE t_date BETWEEN #start_date# AND #end_date#
ORDER BY t_date
</cfquery>
The IDs for the records that fall within this range are captured in this query (e.g., report_ids 142, 153, 179 and 180 are found in this query).
What I'd like to do is place the results of that query (142, 153, 179, and 180) and put them in the WHERE clause of another query to find all the records in another table that match those IDs. Do I need to incorporate a CFLOOP in the query? How would I do this?