标签:指定 code reverse count 字符 ever res 多个 style
mysql> SELECT NOW(); +---------------------+ | NOW() | +---------------------+ | 2019-10-19 10:55:28 | +---------------------+ 1 row in set (0.00 sec)
mysql> SELECT DATE_FORMAT(NOW(),‘%Y年-%m月-%d日 %H时:%i分:%s秒‘); +----------------------------------------------------+ | DATE_FORMAT(NOW(),‘%Y年-%m月-%d日 %H时:%i分:%s秒‘) | +----------------------------------------------------+ | 2019年-10月-19日 11时:03分:01秒 | +----------------------------------------------------+ 1 row in set (0.00 sec)
mysql> SELECT DATE_ADD(NOW(),INTERVAL 1 DAY); +--------------------------------+ | DATE_ADD(NOW(),INTERVAL 1 DAY) | +--------------------------------+ | 2019-10-20 11:07:47 | +--------------------------------+ 1 row in set (0.00 sec)
注意:\expr:正数(加)、负数(减)
\unit:支持毫秒microsecond、秒second、小时hour、天day、周week、年year
mysql> SELECT CONCAT(‘My‘,‘SQL‘); +--------------------+ | CONCAT(‘My‘,‘SQL‘) | +--------------------+ | MySQL | +--------------------+ 1 row in set (0.00 sec)
mysql> SELECT FIELD(‘C‘,‘A‘,‘B‘,‘C‘,‘D‘); +----------------------------+ | FIELD(‘C‘,‘A‘,‘B‘,‘C‘,‘D‘) | +----------------------------+ | 3 | +----------------------------+ 1 row in set (0.00 sec)
mysql> SELECT LOWER(‘ABCD‘); +---------------+ | LOWER(‘ABCD‘) | +---------------+ | abcd | +---------------+ 1 row in set (0.00 sec)
mysql> SELECT REVERSE(‘ABCD‘); +-----------------+ | REVERSE(‘ABCD‘) | +-----------------+ | DCBA | +-----------------+ 1 row in set (0.00 sec)
mysql> SELECT ABS(-10); +----------+ | ABS(-10) | +----------+ | 10 | +----------+ 1 row in set (0.00 sec)
mysql> SELECT ROUND(1.2345); +---------------+ | ROUND(1.2345) | +---------------+ | 1 | +---------------+ 1 row in set (0.00 sec)
mysql> SELECT RAND(); +--------------------+ | RAND() | +--------------------+ | 0.5442781900468079 | +--------------------+ 1 row in set (0.00 sec)
mysql> SELECT POW(4,2); #4的2次方 +----------+ | POW(4,2) | +----------+ | 16 | +----------+ 1 row in set (0.00 sec)
#返回 Products 表中Price 字段的平均值 mysql> SELECT AVG(price) AS AveragePrice FROM Products;
#返回 Products 表中 products 字段总共有多少条记录: mysql> SELECT COUNT(id) AS NumberOfProducts FROM Products;
#返回数据表 Products 中字段 Price 的最大值:
mysql> SELECT MAX(Price) AS LargestPrice FROM Products;
#返回数据表 Products 中字段 Price 的最小值: mysql> SELECT MIN(Price) AS SmalltPrice FROM Products;
#计算 Products表中字段 Cost的总和: mysql> SELECT SUM(Cost) AS TotalCost FROM Products;
mysql> SELECT GROUP_CONCAT(name) from crm_product; +-----------------------+ | GROUP_CONCAT(name) | +-----------------------+ | 磷酸铁锂电池,叠片电池 | +-----------------------+ 1 row in set (0.00 sec)
标签:指定 code reverse count 字符 ever res 多个 style
原文地址:https://www.cnblogs.com/shenjianping/p/11703252.html