User Guide

Table Of Contents
498 Chapter 22: Using Query of Queries
Using joins
A join operation uses a single SELECT statement to return a result set from multiple, related
tables, typically those with a primary key - foreign key relationship. There are two SQL clauses
that perform joins:
WHERE clause ColdFusion supports joins through a WHERE clause.
INNER JOIN and OUTER JOIN ColdFusion does not support joins through INNER JOIN
or OUTER JOIN clauses.
Note: Query of Queries supports joins between two tables only.
Using unions
The UNION operator lets you combine the results of two or more SELECT expressions into a
single record set. The original tables must have the same number of columns, and corresponding
columns must be UNION-compatible data types. Columns are UNION-compatible data types if
they meet one of the following conditions:
The same data type; for example, both Tinyint
Both Numeric; for example, Tinyint, Smallint, Integer, Bigint, Double, Float, Real, Decimal,
or Numeric
Both Characters; for example, Char, Varchar, or LongVarchar
Both Dates; for example, Time, TimeStamp, or Date
Note: Query Of Queries does not support ODBC-formatted dates and times.
Syntax
select_expression = select_expression UNION [ALL] select_expression
Example
This example uses the following tables:
Table1
Type(int) Name(varchar)
1Tennis
2 Baseball
3 Football
Table2
ID(int) Sport(varchar)
3 Football
4 Volleyball
5PingPong