Predicates are conditions you write in the WHERE, ON, and HAVING clauses of a SQL statement that determine which rows are affected, or returned, by that statement. For example, use the predicate name = 'Wagner Falls' to return data for only that particular waterfall:

SELECT, u.northing, u.easting
FROM upfall u
WHERE name = 'Wagner Falls';

Table 14 lists the available comparison operators. Some operators, such as IN and EXISTS, are more fully described in upcoming subsections. Regular-expression operators are described later in the "Regular Expressions" section. Operators for dealing with nulls are described in "Nulls.”

Table 14. Comparison operators



!=, <>

Tests for inequality


Tests for less than


Tests for less than or equal to


Null-safe test for equality; supported only by MySQL


Tests for equality


Tests for greater than


Tests for greater than or equal to


Tests whether a value lies within a given range


Tests whether rows exist matching conditions that you specify


Tests whether a value is contained in a set of values that you specify or that are returned by a subquery


Tests for nullity


Tests whether a value matches a pattern


Regular-expression comparison operator; supported only by MySQL


Tests whether a value matches the pattern described by a regular expression; supported only by Oracle

EXISTS Predicates

Use EXISTS ...

Get SQL Pocket Guide, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.