MySQL进阶之路五(运算符)

#运算符
1,算数运算符(+ - * /)
select 1+1;
select 1-1;
select 1*2;
select 1/3; 0.3333---double 类型
select 3 div 2;   整除
select 3/0;  null 

2.比较运算符(=  !=  >=  <=)
select 1 != 1;   0
# is null /is not null /between  ... and .../在某个范围内,
# in/not in 是否在集合内
select * from classroom where cid =3
select * from classroom where description is null

3.逻辑运算符(and  or  !)与或非
select 1=1 and 1=2;
select 1=1 or 1=2;
select !1 = 1;

4.位运算符(&  | ^)与,或,异或
select 3 & 2; #2  按位与
select 3 | 2; #3	按位或
select 3 ^ 2; #1	按位异或

select * from  classroom where ...

select 子句作用,字段值
from 子句作用,从哪个表或者冲那个结果集中查询
where 子句作用,条件

猜你喜欢

转载自blog.csdn.net/ZhaiAlan/article/details/92794454
今日推荐