Go to the first, previous, next, last section, table of contents.


String comparison functions.

expr IN (value,...)
Returns 1 if expr is any of the values in the IN list, else it returns 0. If all values are constants, then all values are evaluated according to the type of expr and sorted. The search for the item is then done by using a binary search. This means IN is very quick when used with constants in the IN part.
mysql> select 2 in (0,3,5,'wefwf');               ->      0
mysql> select 'wefwf' in (0,3,5,'wefwf');         ->      1
expr NOT IN (value,...)
Same as NOT (expr IN (value,...))
expr LIKE expr
SQL simple regular expression comparison. Returns 1 (TRUE) or 0 (FALSE). With LIKE you have two wild characters.
% Matches any number of characters, even zero characters.
_ Matches exactly one character.
\% Matches one %.
\_ Matches one _.
mysql> select 'David!' like 'David_';             ->      1
mysql> select 'David!' like 'David\_';            ->      0
mysql> select 'David_' like 'David\_';            ->      1
mysql> select 'David!' like '%D%v%';              ->      1
mysql> select 10 like '1%';                       ->      1
LIKE is allowed on numerical expressions! (Extension)
  • expr NOT LIKE expr Same as NOT (expr LIKE expr).
  • expr REGEXP expr
  • expr RLIKE expr Checks string against extended regular expr. See section Description of MySQL regular expression syntax.. RLIKE is for mSQL compatibility. NOTE: Because MySQL uses the C escape syntax in strings (\n) You must double any '\' that you uses in your REGEXP strings.
    mysql> select 'Monty!' regexp 'm%y%%';            ->      0
    mysql> select 'Monty!' regexp '.*';               ->      1
    mysql> select 'new*\n*line' regexp 'new\\*.\\*line'
    
  • expr NOT REGEXP expr Same as NOT (expr REGEXP expr).
  • STRCMP() Returns 0 if the strings are the same. Otherwise return -1 if the first argument is smaller according to the current sort-order, otherwise return 1.
    mysql> select strcmp('text', 'text2');            -> -1
    mysql> select strcmp('text2', 'text');            -> 1
    mysql> select strcmp('text', 'text');             -> 0
    

  • Go to the first, previous, next, last section, table of contents.