PolarDB allows you to use the traditional SQL LIKE operator to implement pattern matching.
Syntax
The following example shows the syntax of the LIKE operator:
string LIKE pattern [ ESCAPE escape-character ]
string NOT LIKE pattern [ ESCAPE escape-character ]
Each pattern parameter defines a set of strings. If the set of strings represented by pattern contains the value that is specified by the string parameter, the LIKE expression returns true. A NOT LIKE expression has a reciprocal inverse relationship with a LIKE expression that contains the same string and pattern parameters. If the LIKE expression returns true, the NOT LIKE expression returns false. The NOT LIKE expression is equivalent to NOT (string LIKE pattern).
If the pattern parameter does not contain percent signs (%) or underscores (_), the specified pattern represents only the string itself. In this case, the LIKE operator acts as an equal sign operator. An underscore (_) in the pattern parameter matches a single arbitrary character. A percent sign (%) matches an arbitrary string of zero or more characters.
Examples
'abc' LIKE 'abc' true
'abc' LIKE 'a%' true
'abc' LIKE '_b_' true
'abc' LIKE 'c' false
'abc' LIKE '%b%' true
'abc_d' LIKE '%\_%' true
'abc%d' LIKE '%\%%' true
'abc_d' LIKE '%/_%' ESCAPE '/' true
'abc\d' LIKE '%\\%' true
'ab\c' LIKE '%\\%' true
'ab\\c' LIKE '%\\\\%' true
'ab\\c' LIKE '%\\%' ESCAPE '/' true
'abc%d' LIKE '%\%%' true
'abc%d' LIKE '%\%%' ESCAPE '' false