Database Reference
In-Depth Information
Equi (=), anti (!=, <>), and range (<, >, =<, >=) comparison condi-
tions are used between two expressions. A table column name is an
expression.
expression [ = | != | > | < | >= | <= ] expression
For example:
SELECT * FROM ARTIST WHERE ARTIST_ID = 1;
SELECT * FROM ARTIST WHERE ARTIST_ID <> 1;
SELECT * FROM ARTIST WHERE ARTIST_ID <= 5;
A subquery is also an expression, so the following applies. This
comparison condition allows a single-row subquery only. A single-
row subquery returns a single row only. See Chapter 12 for details on
subqueries.
(subquery) [ = | != | > | < | >= | <= ] (subquery)
LIKE pattern-matches between strings, those strings being expres-
sions. LIKE also requires single-row subqueries if used with a sub-
query.
expression LIKE expression
For example:
SELECT * FROM ARTIST WHERE NAME LIKE '%a%';
The percentage sign (%) and the underscore/underbar (_) charac-
ters are pattern-matching wild card characters. A wild card character
can match any character. More specifically, the percentage sign (%) is
used as a pattern-matching character representing zero or more char-
acters in a subset of a string. The underscore/underbar character (_) is
used to represent one and only one character. The previous query
will find all artists with a letter “a” anywhere in their names. The next
example will only find artists with a letter “a” in the second position
of their names.
SELECT * FROM ARTIST WHERE NAME LIKE '_a%';
Search WWH ::




Custom Search