OK, I just can't seem to get this. It should be super easy for most of
you to answer.
I have 2 tables that are similar in design. 1st is called
"Applications". The 2nd is called "ExtraApplications". They both
contain vehicle "Year", "Make", "Model" and "Engine" columns. I need to
pull the unique records from both tables simultaneously.
For example, I am currently pulling the "Year" from the Applications
table like this:
<cfquery name="GetYear" datasource="ds" username="un" password="pw">
SELECT DISTINCT Year
FROM applications
ORDER BY Year DESC
</cfquery>
Very simple. Now, how do I join the ExtraApplications table in that
same query to pull all unique records from both??
Thanks in advance!
andrewst@onetel.com - 26 Jan 2005 15:56 GMT
SELECT Year
FROM applications
UNION
SELECT Year
FROM extraapplications
ORDER BY Year DESC
Jarl Hermansson - 26 Jan 2005 16:03 GMT
sams@centric.net wrote in news:1106753968.884736.111010
@c13g2000cwb.googlegroups.com:
> OK, I just can't seem to get this. It should be super easy for most of
> you to answer.
[quoted text clipped - 15 lines]
> Very simple. Now, how do I join the ExtraApplications table in that
> same query to pull all unique records from both??
SELECT Year FROM Applications
UNION
SELECT Year FROM ExtraApplications
ORDER BY Year DESC
UNION adds one result set to another, then all duplicates are removed.
Note that YEAR is a reserved word in SQL. To avoid future problems,
consider another column name.
HTH,
Jarl
sams@centric.net - 26 Jan 2005 16:12 GMT