string REGEXP pattern

Description: Looks for pattern within string, performing a pattern-match comparison using extended regular expressions, returning TRUE if a match is obtained or FALSE if not.

Note that any \ that you use as an escape character within pattern must be doubled—that is, you must use \\.

Examples:

  • 'Smith' RLIKE '^sm' returns 1.

  • 'Smith' RLIKE BINARY '^sm' returns 0.

  • 'Smith' RLIKE '[0-9]$' returns 0.

  • 'Smith45' RLIKE '[0-9]$' returns 1.

  • 'Line1\nLine2' RLIKE '\\n' returns 1.

See also: LIKE, and Day 10, “Operators and Functions in MySQL,” for more about regular expressions

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.