ใช้ operator RLIKE (regex) ความสำคัญคือจำนวน backslash ในคิวรี่ ตัวอย่างตาราง backslashes:
mysql> select * from backslashes; +------+-------+ | Id | Value | +------+-------+ | 1 | 200 | | 2 | 300 | | 4 | a\\b | | 3 | a\b | +------+-------+ 4 rows in set (0.10 sec)
ค้นหา a\\b (มี backslash 2 ตัวในข้อมูล) ต้องเขียน backslash 8 ตัวในคิวรี่ (double escaping 2 ระดับ: client และ server):
mysql> Select * from backslashes where value RLIKE 'a\\\\\\\\b'; +------+-------+ | Id | Value | +------+-------+ | 4 | a\\b | +------+-------+ 1 row in set (0.00 sec)
ค้นหา a\b (backslash เดียว) ใช้ 4 backslash:
mysql> Select * from backslashes where value RLIKE 'a\\\\b'; +------+-------+ | Id | Value | +------+-------+ | 3 | a\b | +------+-------+ 1 row in set (0.01 sec)