我正在执行两个查询以从同一数据库中的两个表中的数据构建一个表。我现在拥有的代码如下,但我知道这样做会造成不必要的负载。我一直在尝试加入表格以获得相同的结果,但没有运气。有输入吗?
<cfquery name="GetWeekends">
SELECT id, weekend_type, community_id, start_date, end_date, language
FROM _weekends
WHERE weekend_type = 1 and start_date > Now()
ORDER BY start_date ASC
</cfquery>
<cfloop query="GetWeekends">
<cfquery name="GetCommunity">
SELECT community_id, location, language, state, country
FROM _communities
WHERE community_id = #getweekends.community_id#
</cfquery>
<tr>
<td>#DateFormat(start_date, "mm/dd/yyyy")#</td>
<td>#GetComm.location#</td>
<td>#GetComm.state#</td>
<td>#GetComm.country#</td>
<td>#GetComm.language#</td>
</tr>
</cfloop>