1、ceil()
SELECT ceil(4.01);/*output:5*/
ceil()函数用于向上取整
2、floor()
SELECT floor(4.99);/*output:4*/
floor()函数用于向下取整
3、round()
SELECT round(4.99);/*output:5*/
round()函数表示四舍五入
4、truncate()
SELECT truncate(145.123,2);/*output:145.12*/
SELECT truncate(145.123,1);/*output:145.1*/
SELECT truncate(145.123,-1);/*ouput:140*/
truncate()函数用于数字截断(不会进行四舍五入),其中第二个参数表示小数点后保留的位数(为负数的话看第三条语句就能明白)
5、mod
SELECT 8 MOD 3;/*output:2*/
mod是一个运算符,表示求余数
6、div
SELECT 3 DIV 4;/*output:0*/
SELECT 4 DIV 4;/*output:1*/
SELECT 9 DIV 4;/*output:2*/
div表示整数除法,返回值是一个整数
7、[ not ] between...and...
SELECT 3 BETWEEN 1 AND 9;/*output:1*/
SELECT 3 BETWEEN 4 AND 9;/*output:0*/
[ not ] between...and...表示【不】在某个区间
8、[ not ] in (...)
SELECT 3 IN (1,2,3,4);/*output:1*/
SELECT 3 IN (1,2,4,5);/*output:0*/
[ not ] in (...)表示【不】在给定的值之中
9、is [ not ] null
SELECT 3 IS NULL ;/*output:0*/
SELECT 3 IS NOT NULL ;/*output:1*/
is [ not ] null判断给定的数值或字符串是否为空,注意:null是null,""不是null,0不是null