You can do this with the UNION operator in SQL. You write one CFQUERY, and
the SQL inside does a UNION between three individual selects. If you want
to be able to differentiate between the result sets, you would also select a
constant, so it would look something like this:
<CFQUERY NAME="GetDetails" DATASOURCE="#datasource#">
SELECT 'Sender' as DetType, UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#Session.UserNumber#
UNION
SELECT 'Orderer' as DetType, UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#GetOrder.UserNumber#
UNION
SELECT 'Approver' as DetType, UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#GetOrder.ApprovalBy#
</CFQUERY>
If you don't want to eliminate duplicates, you would use UNION ALL
Bob
P.S. Field types need to be compatible for this to work, but I am assuming
they are in your case as the names are all the same.
-----Original Message-----
From: Gene Kraybill [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 29, 2000 2:21 PM
To: CF-Talk
Subject: OT: combining SQL queries
<CFQUERY NAME="GetSenderDetails" DATASOURCE="#datasource#">
SELECT UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#Session.UserNumber#
</CFQUERY>
<CFQUERY NAME="GetOrdererDetails" DATASOURCE="#datasource#">
SELECT UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#GetOrder.UserNumber#
</CFQUERY>
<CFQUERY NAME="GetApproverDetails" DATASOURCE="#datasource#">
SELECT UserName, FirstName, LastName, Email
FROM Users
WHERE UserNumber=#GetOrder.ApprovalBy#
</CFQUERY>
Any way to combine these three queries and still be able to reference the
Sender,
Orderer and Approver in my output?
Gene Kraybill
---------------------------------
Gene Kraybill
LPW & Associates LLC
www.lpw.net
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.