I am executing two queries to build a table off of data from two tables in the same database. The code I have now is below, but I know I am creating an unnecessary load doing it this way. I have been trying to join the tables to get the same result, but have had no luck. Any input?
SELECT id, weekend_type, community_id, start_date, end_date, language
WHERE weekend_type = 1 and start_date > Now()
ORDER BY start_date ASC
SELECT community_id, location, language, state, country
WHERE community_id = #getweekends.community_id#
Database joins are pretty basic. You'd do well to educate yourself about them.
In any event, it looks like you want to do something like this:
<cfquery name="GetWeekends"> SELECT w.id, w.weekend_type, w.community_id, w.start_date, w.end_date, w.language, c.community_id, c.location, c.language, c.state, c.country FROM _weekends w INNER JOIN _communities c ON w.community_id=c.community_id WHERE w.weekend_type = 1 and w.start_date > Now() ORDER BY w.start_date ASC </cfquery>