数值函数
进1法:CEIL 退1法:FLOOR 四舍五入:ROUND
1 row in set (0.00 sec)
1 row in set (0.00 sec)
除法取商:DIV 除法取余:MOD
1 row in set (0.00 sec)
幂运算: POWER 小数截取: TRUNCATE
1 row in set (0.00 sec)
在(不在)区间内:(NOT)BETWEEN…AND…
在(不在)枚举内:(NOT)IN(v1,v2,v3…)
是(否)为空:IS(NOT) NULL
1 row in set (0.00 sec)
日期显示:
1 row in set (0.03 sec)
日期变换:
mysql> SELECT DATE
_ADD('2018-5-17',INTERVAL 365 DAY),
-> DATEDIFF('2018-5-17','2016-2-17'),
-> DATE_FORMAT(
'2018-5-17',
'%m/%d/%Y');
+----------------------------------------+-----------------------------------
+-------------------------------------+
1 row in set (0.00 sec)
连接ID,数据库名,用户名,版本号
1 row in set (0.00 sec)
1 row in set (0.00 sec)
最后插入的id值:LAST_INSERT_ID()(一次插入多条记录,为最先插入id)
mysql> ALTER TABLE 名单 ADD id SMALLINT UNSIGNED PRIMARY KEY AUTO
_INCREMENT FIRST;
Query OK, 0 rows affected (0.27 sec)
Records: 0 Duplicates: 0 Warnings: 0
| id | smallint(5) unsigned | NO | PRI | NULL | auto
_increment |
| 姓 | varchar(12) | NO | | NULL | |
| 名 | varchar(24) | NO | | NULL | |
+-------+----------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> SELECT*FROM 名单;
+----+--------+-----+
| id | 姓 | 名 |
+----+--------+-----+
| 1 | 张 | 飞 |
| 2 | 刘 | 备 |
| 3 | 关 | 羽 |
| 4 | 诸葛 | 亮 |
| 5 | 赵% | 云 |
+----+--------+-----+
5 rows in set (0.00 sec)
mysql> INSERT 名单 VALUES(NULL,'马','超');
Query OK, 1 row affected (0.00 sec)
| 1 | 张 | 飞 |
| 2 | 刘 | 备 |
| 3 | 关 | 羽 |
| 4 | 诸葛 | 亮 |
| 5 | 赵% | 云 |
6 rows in set (0.00 sec)
1 row in set (0.00 sec)
聚合函数:平均数:AVG、个数:COUNT、最大值:MAX、最小值:MIN、和:SUM
1 row in set (0.00 sec)
MD5加密
1 row in set (0.00 sec)
转载于:https://www.cnblogs.com/toly-top/p/9782015.html