and number of columns for the union to work. If one query has an extra
column as yours does, alias the other query and set it to NULL.
SELECT col1, col2, col3, col5 = NULL
FROM table1
UNION
SELECT col1, col2, col4 AS 'col3', col5
FROM table2
That's a rough guess though, it's been a while since I've done this.
Ade
-----Original Message-----
From: Mark Leder [mailto:[EMAIL PROTECTED]
Sent: 09 December 2003 16:40
To: CF-Talk
Subject: SQL UNION Trouble
In the following query I want the email addresses from two different tables
to be grouped together (for sending in CFMail), can't get it to work, what
am I missing? (BTW: the individual queries work just not as a UNION)
<cfquery name="qMailMessage" datasource="#REQUEST.dsnSQL#"
username="#REQUEST.dsnUID#" password="#REQUEST.dsnPWD#">
SELECT L.email, L.firstname, L.lastname
FROM #REQUEST.prefix#_Members_List L
WHERE L.email IS NOT NULL
UNION
SELECT A.assistantfirstname, A.assistantLastName,
A.assistantEmail AS A.email
FROM #REQUEST.prefix#_Members_AssistantInfo A
WHERE A.email IS NOT NULL
ORDER BY email
</cfquery>
Thanks, Mark
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

