mysql函数

# 从字符串 RUNOOB 中的第 2 个位置截取 3个 字符:
# SELECT MID("RUNOOB", 2, 3) AS ExtractString; -- UNO
# select MID(houTransactionTime, 1, 7) AS houTransactionTime from house;

# 返回字符串 runoob 中的前两个字符:
# 例子 SELECT LEFT('runoob',2) -- ru
# select LEFT(houTransactionTime,7) from house;

# 将字符串 abc 中的字符 a 替换为字符 x:
# SELECT REPLACE('abc','a','x') --xbc

# 返回 Products 表中 products 字段总共有多少条记录:
# SELECT COUNT(ProductID) AS NumberOfProducts FROM Products;

# 返回数据表 Products 中字段 Price 的最大值:
# SELECT MAX(Price) AS LargestPrice FROM Products;

# 返回数据表 Products 中字段 Price 的最小值:
# SELECT MIN(Price) AS MinPrice FROM Products;

# 计算 OrderDetails 表中字段 Quantity 的总和:
# SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;

# 返回数值 x 保留到小数点后 y 位的值(与 ROUND 最大的区别是不会进行四舍五入)
# SELECT TRUNCATE(1.23456,3) -- 1.234

# 返回 Products 表中Price 字段的平均值:
# SELECT AVG(Price) AS AveragePrice FROM Products;
原文地址:https://www.cnblogs.com/mrfanqie/p/mysql1551.html