I l @ ve RuBoard |
Essentially, all string operators return implicit Boolean true or false values given the supplied comparison. (The exception is the concatenation operators shown in the next "Listing" section.) When making comparisons, the characters ' location in the ANSI chart is taken into account. Therefore, a lowercase "a" is seen as less than (<) an uppercase "A." String operators make use of regular expression matching. This expression matching includes an internal format and a POSIX-compliant format. PostgreSQL can make use of two distinct types of pattern matching: an ANSI-SQL method and a POSIX regex style. The internal ANSI-SQL style makes use of the LIKE and NOTLIKE keywords. This ANSI-SQL method can use the following wildcards for pattern matching:
Conversely, the POSIX-compliant operators use the standard regex comparisons, such as the following:
A full discussion of POSIX-style regular expressions is beyond the scope of this book. See the man pages for sed , awk , and egrep for more information on POSIX-style regex. The regex engine included with most versions of PostgreSQL is the POSIX 1003.2 "egrep" style. This regex library, by Henry Spencer, is included in many other popular applications. More information on the regex engine included in a specific version of PostgreSQL can usually be found in the source directory $ SOURCE/backend/ regex . Listing
Notes/ExamplesSelect all records from a table where the first name is Bob : SELECT * FROM authors WHERE firstname='Bob'; Select all records from a table, except those named Bob : SELECT * FROM authors WHERE firstname<>'Bob'; Select all records where the first name begins with Bo : SELECT * FROM authors WHERE firstname LIKE 'Bo'; Select all records where the first name begins with b , regardless of case: SELECT * FROM authors WHERE firstname ILIKE 'b'; |
I l @ ve RuBoard |