運算符操作
阿新 • • 發佈:2018-08-31
class 諸葛 諸葛亮 單個字符 fan 範圍 country 條件 like
1、數值比較/字符比較
1、數值比較 := != > >= < <=
2、字符比較 := !=
2、邏輯比較
1、and (兩個或多個條件同時成立)
2、or (任意一個條件成立即可)
3、範圍內比較
1、where 字段名 between 值1 and 值2
2、where 字段名 in(值1,值2,...)
3、where 字段名 not in(值1,值2,...)
select * from sanguo where ((id in(1,3,4)) and country = "蜀國") or name = "貂蟬"; +------+-----------+--------+--------+------+---------+ | id | name | gongji | fangyu | sex | country | +------+-----------+--------+--------+------+---------+ | 1 | 諸葛亮 | 120 | 20 | 男 | 蜀國 | | 3 | 關羽 | 188 | 60 | 男 | 蜀國 | | 6 | 貂蟬 | 666 | 10 | 女 | 魏國 | +------+-----------+--------+--------+------+---------+
4、匹配空、非空
1、空 :where name is null
2、非空:where name is not null
3、註意
1、NULL :空值,只能用 is 或者 is not 去匹配
2、"" :空字符串,用 = 或者 != 去匹配
5、模糊比較
1、where 字段名 like 表達式
2、表達式
1、_ : 匹配單個字符
2、% : 匹配0到多個字符
## NULL不會被統計,只能用is、is not去匹配
運算符操作