标签:
常见的数值函数下面几个:
SELECT 3+4;
SELECT 3%4;
SELECT CEIL(3.01);
SELECT FLOOR(3.99);
SELECT 3/4;
SELECT 3 DIV 4;
SELECT 5 MOD 3;
SELECT POWER(3,3);
SELECT ROUND(3.652,2);
SELECT ROUND(3.652,1);SELECT ROUND(3.652,0);
SELECT TRUNCATE(125.89,0);
SELECT TRUNCATE(125.89,-1);
常见的比较运算符和函数:
SELECT 15 BETWEEN 1 AND 22;
SELECT 35 BETWEEN 1 AND 22;SELECT 35 NOT BETWEEN 1 AND 22;
SELECT 13 IN(5,10,15,20);
SELECT NULL IS NULL;
SELECT ‘‘ IS NULL;SELECT 0 IS NULL;
SELECT * FROM test WHERE first_name IS NULL;
SELECT * FROM test WHERE first_name IS NOT NULL;
常用的日期时间函数:
SELECT NOW();
SELECT CURDATE();SELECT CURTIME();
SELECT DATE_ADD(‘2016-5-1‘,INTERVAL 23 DAY);
SELECT DATE_ADD(‘2016-5-1‘,INTERVAL -23 DAY);SELECT DATE_ADD(‘2016-5-1‘,INTERVAL 3 WEEK);
SELECT DATEDIFF(‘2016-5-1‘,‘2016-5-23‘);
SELECT DATEDIFF(‘2016-5-15‘,‘2016-5-3‘);SELECT DATE_FORMAT(‘2016-5-2‘,‘%m/%d/%Y‘);
MySQL学习18:运算符与函数之数值运算符和函数、比较运算符和函数、日期时 间函数
标签:
原文地址:http://blog.csdn.net/erlian1992/article/details/51590090