MySQL中的WHERE子句

版權聲明:本文爲博主原創文章,轉載請註明出處和鏈接。 https://blog.csdn.net/a781568222/article/details/68927129

where子句中的運算符:

    <,>,=,!=,>=,<=,in(),between""and"",and,not,or,like

1、其中 <,>,=,!=,>=,<=,in(),between and 屬於比較運算符

       in(A,B):表示包含A和B的結果

between 1 and 5 :會查出在1和5之間的值包括1和5

2、and,not,or屬於邏輯運算符

select * from user where age>4 and age <14 : 查詢的出來的結果集中的age處於4和14之間,不包括4和14

select * from user where age>4 or age <3 : 查詢的出來的結果集中的age有大於4的也有小於3的,不包括4和3

select * from user where not age>4 :查詢的出來的結果集中的age沒有大於4,可以等於4

3、、like是模糊查詢

select * from user where phone like '130%' 查詢出user表中phone爲130開頭的用戶

select * from user where phone like '130_' 查詢出user表中phone爲130開頭後面只有一位的用戶,比如1301

select * from user where phone like '%130%' 查詢出user表中phone中含有130的用戶

select * from user where phone like '%130'查詢出user表中phone爲130結尾的用戶

%爲通配符,不限定位數

_也是通配符,一個表示一位

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章