MariaDB比較運算符

MongoDB比較運算符用於測試等於或不等於,還有其他更高級的運算符。

WHERE子句中使用比較運算符來確定要選擇的記錄。以下是可以在MariaDB中使用的比較運算符的列表:

語法及示例 -

編號 比較運算符 描述 示例
1 = 比較等於 select * from students where id=100
2 <=> 比較等於(安全比較NULL值) select * from students where student_name<=>'Maxsu'
3 <> 比較不等於 select * from students where student_name<>'Maxsu'
4 != 比較不等於 select * from students where student_name!='Maxsu'
5 > 比較大於 select * from students where student_id>5
6 >= 比較大於或等於 select * from students where student_id>=5
7 < 比較小於 select * from students where student_id<5
8 <= 比較小於或等於 select * from students where student_id<=5
9 in ( ) 匹配列表中的值 select * from students where student_id IN(1,3,6)
10 not 否定一個條件 select * from students where student_id NOT IN(1,3,6)
11 between 匹配在一個範圍內(含) select * from students where student_id between 1 AND 3)
12 is null 判斷是否為NULL select * from students where student_address IS NULL
13 is not null 判斷是否為非NULL select * from students where student_address IS NOT NULL
14 like %_模式匹配 select * from students where student_name LIKE 'Ma%'
15 exists 如果子查詢返回至少一行,則滿足條件。

上一篇: MariaDB右外連接 下一篇: MariaDB Union運算符