MySQL基础 函数

1、文本处理函数


Soundex()对字符串进行发音比较的函数

select name,contact from person_info where Soundex('Y.Lee')=Soundex(name)\g

2、日期处理函数


注:首选的日期格式是‘1900-11-03’

示例:可靠的检索某一天的记录(用Date(...)提取日期) select name from person_info where Date(birth) = '1900-07-08'\g      示例:过滤检索九月份的订单

方法一:用于天数固定的九月

select trade_id 
from trade_info 
where Date(trade_time) between '1990-09-01' and '1990-09-30'\g

方法二:无关于天数

select trade_id
from trade_info
where Month(trade_time)=9 and Year(trade_time)=1900

3、常用的数值处理函数


4、常用的聚集函数


count函数注意事项:如果使用count(*)则无论记录是否为null,都会被计算进去,如果对特定列,如count(column_name)则会忽略其中NULL的计数。其他函数类似,不统计NULL

5、聚集不同的值。 如:avg(DISTINCT price),其余的几个函数类似,但是不能使用count(distinct *)


猜你喜欢

转载自blog.csdn.net/qq_24888697/article/details/81012655
今日推荐