Skip to main content
Inspiring
September 7, 2009
Question

Append two or more query result -CFC

  • September 7, 2009
  • 1 reply
  • 5029 views

Hi all,

How will i append one and/ or two and/ or three query result in a cfc? I will pass variable which may contain list ={datasourceName1,datasourceName2,datasourceName3}

I am using SQL 2005...All 3 db has same table names...cfargument param is a list which may contain datasourceName1 and/ or datasourceName2 and/ or datasourceName3

Currently I have ...

<cfcomponent>

<cffunction>

<cfquery datasource='datasourceName1' name='q1'>

select * from location

</cfquery>

<cfreturn q1>

<cfquery datasource='datasourceName2' name='q2>

select * from location

</cfquery>

<cfreturn q2>

<cfquery datasource='datasourceName3' name='q3>

select * from location

</cfquery>

<cfreturn q3>

</cffunction>

This topic has been closed for replies.

1 reply

Inspiring
September 8, 2009

Read up on Query on Query: http://livedocs.adobe.com/coldfusion/8/htmldocs/using_recordsets_1.html.

You can UNION queries together, provided the columns can be mapped in a common way (which will probably not be an issue for you).

--

Adam

emmim44Author
Inspiring
September 8, 2009

That doesnt help much.... Any other input appreciated....

Inspiring
September 8, 2009

In what way does it not help?  Maybe I'm misunderstanding your requirement... you want to append query results together, right?  And you'd do that by using a QoQ and unioning them...

Am I misunderstandind your requirement?

--

Adam