User Guide

Table Of Contents
502 Chapter 22: Using Query of Queries
IN conditional
This conditional lets you specify a comma-delimited list of conditions to match. It is similar in
function to the OR conditional. In addition to being more legible when working with long lists,
the IN conditional can contain another SELECT statement.
Syntax
in_cond ::= expression [NOT] IN (expression_list)
Example
The following example uses the IN conditional to retrieve only those dogs who were born at
either Kens Kennels or Barbs Breeders:
SELECT dog_name, dog_IQ, Kennel_ID
FROM Dogs
WHERE kennel_ID IN ('Kens','Barbs');
LIKE conditional
This conditional lets you perform wildcard searches, in which you compare your data to search
patterns. This strategy differs from other conditionals, such as BETWEEN or IN, because the
LIKE conditional compares your data to a value that is partially unknown.
Syntax
like_cond ::= left_string_exp [NOT] LIKE right_string_exp [ESCAPE escape_char]
The left_string_exp can be either a constant string, or a column reference to a string column. The
right_string_exp can be either a column reference to a string column, or a search pattern. A search
pattern is a search condition that consists of literal text and at least one wildcard character. A
wildcard character is a special character that represents an unknown part of a search pattern, and is
interpreted as follows:
The underscore (_) represents any single character.
The percent sign (%) represents zero or more characters.
Square brackets ([ ]) represents any character in the range.
Square brackets with a caret [^] represent any character not in the range.
All other characters represent themselves.
Note: Earlier versions of ColdFusion do not support bracketed ranges.
Examples
The following example uses the LIKE conditional to retrieve only those dogs of the breed Terrier,
whether the dog is a Boston Terrier, Jack Russell Terrier, Scottish Terrier, and so on:
SELECT dog_name, dog_IQ, breed
FROM Dogs
WHERE breed LIKE '%Terrier';