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
9in ( )匹配列表中的值select * from students where student_id IN(1,3,6)
10not否定一个条件select * from students where student_id NOT IN(1,3,6)
11between匹配在一个范围内(含)select * from students where student_id between 1 AND 3)
12is null判断是否为NULLselect * from students where student_address IS NULL
13is not null判断是否为非NULLselect * from students where student_address IS NOT NULL
14like%_模式匹配select * from students where student_name LIKE 'Ma%'
15exists如果子查询返回至少一行,则满足条件。
        原文作者:MariaDB教程
        原文地址: https://www.yiibai.com/mariadb/mariadb-comparison-operator.html
        本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
    点赞