O'Reilly logo

Joe Celko's SQL for Smarties, 4th Edition by Joe Celko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20

BETWEEN and OVERLAPS Predicates

The BETWEEN and OVERLAPS predicates both offer a shorthand way of showing that one value lies within a range defined by two other values. BETWEEN works with scalar range limits of all types; the OVERLAPS predicate looks at two time periods (defined either by start and end points or by a starting time and an INTERVAL) to see if they overlap in time.

20.1 The BETWEEN Predicate

The BETWEEN predicate is a feature of SQL that is used enough to deserve special attention. It is also just tricky enough to fool beginning programmers.

<between predicate>

 ::= <row value predicand> <between predicate part 2>

<between predicate part 2> ::=

[NOT] BETWEEN [ASYMMETRIC | SYMMETRIC]

<row value predicand> AND <row value predicand> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required