queryConcat([q1] [, q2])
Last updated February 23, 2006
Version: 1 | Requires: ColdFusion 5 | Library: DataManipulationLib
Description:
Appends queryTwo to queryOne. Sorting is ignored - queryTwo is appended to the end of queryOne. Note that both queries must have the same columns.
Return Values:
Returns a query.
Example:
heads = "First Name,Age";
q1 = queryNew(cols);
queryAddRow(q1,2);
querySetCell(q1,"sName","Joe",1);
querySetCell(q1,"sAge","25",1);
querySetCell(q1,"sName","John",2);
querySetCell(q1,"sAge","30",2);
q2 = queryNew(cols);
queryAddRow(q2,2);
querySetCell(q2,"sName","Kassi",1);
querySetCell(q2,"sAge","19",1);
querySetCell(q2,"sName","Mary",2);
querySetCell(q2,"sAge","20",2);
</cfscript>
<cfdump var="#q1#">
<cfdump var="#q2#">
<br><br>
Resulting query
<br>
<cfset resultQuery = queryConcat(q1, q2)>
<cfdump var="#resultQuery#">
Parameters:
| Name | Description | Required |
|---|---|---|
| q1 | First query. | No |
| q2 | Second query. | No |
Full UDF Source:
<cfscript>
/**
* Concatenate two queries together.
*
* @param q1 First query. (Optional)
* @param q2 Second query. (Optional)
* @return Returns a query.
* @author Chris Dary (umbrae@gmail.com)
* @version 1, February 23, 2006
*/
function queryConcat(q1,q2) {
var row = "";
var col = "";
if(q1.columnList NEQ q2.columnList) {
return q1;
}
for(row=1; row LTE q2.recordCount; row=row+1) {
queryAddRow(q1);
for(col=1; col LTE listLen(q1.columnList); col=col+1)
querySetCell(q1,ListGetAt(q1.columnList,col), q2[ListGetAt(q1.columnList,col)][row]);
}
return q1;
}
</cfscript>
Search CFLib.org
Latest Additions
Adam Cameron added
composeDateTime
17 day(s) ago
Chris Weller added
convertQueryStri...
a while ago
Greg Nettles added
arrayDiff
a while ago
Nathan Dintenfass added
ArrayOfStructsSo...
a while ago
Top Rated
backupDatabase
Rated 5.0, 36 time(s)
indentXml
Rated 5.0, 10 time(s)
deAccent
Rated 5.0, 6 time(s)
countArbitraryDa...
Rated 5.0, 5 time(s)