Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

ประโยชน์ของ RLIKE operator ใน MySQL

RLIKE operator - Pattern matching แบบ Regular Expression

RLIKE operator (synonym ของ REGEXP) ทำ pattern matching ของสตริง expression ต่อกับ pattern ที่ระบุ

ไวยากรณ์

RLIKE Pat_for_match

Pat_for_match = pattern ที่จะ match กับ expression

ตัวอย่าง

mysql> Select Id, Name from Student WHERE Name RLIKE 'v$';
+------+--------+
| Id   | Name   |
+------+--------+
| 1    | Gaurav |
| 2    | Aarav  |
| 20   | Gaurav |
+------+--------+
3 rows in set (0.00 sec)

Wildcard $ หมายถึงสิ้นสุดสตริง ค้นหาชื่อที่ลงท้ายด้วย 'v'