加法运算符
CREATE DATABASE test;-- 建库
USE test;--进库
CREATE TABLE demo1(name CHAR,age INT);--建表
--查询
SELECT 100+'1',100+'a',100+NULL
FROM DUAL;
/*结果
+---------+---------+----------+
| 100+'1' | 100+'a' | 100+NULL |
+---------+---------+----------+
| 101 | 100 | NULL |
+---------+---------+----------+
1 row in set, 1 warning (0.00 sec)
*/
SQL中加号没有连接功能,与字符串相加为一个数
与null运算结果为null;
除法运算符
SELECT 100/2,100/2.0,100/3,100/'a',100/0;
/*结果
+---------+---------+---------+---------+-------+
| 100/2 | 100/2.0 | 100/3 | 100/'a' | 100/0 |
+---------+---------+---------+---------+-------+
| 50.0000 | 50.0000 | 33.3333 | NULL | NULL |
+---------+---------+---------+---------+-------+
1 row in set, 1 warning (0.00 sec)
结果全为浮点数
取模运算
SELECT 12%5,12%-5,-12%5,-12%-5;
/*结果
+------+-------+-------+--------+
| 12%5 | 12%-5 | -12%5 | -12%-5 |
+------+-------+-------+--------+
| 2 | 2 | -2 | -2 |
+------+-------+-------+--------+
*/
取模后的结果符号只与被取数有关
标签:12%,--,运算符,MYSQL,100,NULL,SELECT From: https://www.cnblogs.com/exact/p/16816163.html