Coding for one of my projects recently I ran into a situation where I had to combine two different recordsets from two different tables and combine them as one. This is how I did it using Query of Queries...
<cfquery name="qGetNews" datasource="your_dsn">
SELECT news_id AS articleID, news_title AS articleTitle
FROM tbl_news
</cfquery>
<cfquery name="qGetArticle" datasource="your_dsn">
SELECT article_id AS articleID, article_title AS articleTitle
FROM tbl_article
</cfquery>
<cfquery name="unionAll" dbtype="query">
SELECT * FROM qGetNews
UNION <!--- you can also use UNION ALL --->
SELECT * FROM qGetArticle
ORDER BY articleID
</cfquery>
<cfoutput query="unionAll">
#articleTitle# <br />
</cfoutput>
More info can be found here: http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001265.htm
Recent Comments