September 2nd, 2008

SIMILAR TO (Matching to an Expression)

Posted by admin in D. WHERE Clause

> The SIMILAR operand was introduced by SQL:1999 and gives an alternate method of doing a comparison.
> With SIMILAR you can compare a character string to an expression.

SELECT column1, column2, ...
  FROM table1, table2, ...
 WHERE testcolumn [NOT] SIMILAR TO (expression), ...;

Example:

WHERE DAY_FIELD SIMILAR TO
      '('Day=' (Mon | Tue | Wed | Thu | Fri))'

or

WHERE COLOR SIMILAR TO
      '('The color is ' (red | green | blue | 12 | 14))'

Comments are closed.

Sorry, the comment form is closed at this time.