Home  >  Article  >  Database  >  mysql笔记4_函数_MySQL

mysql笔记4_函数_MySQL

WBOY
WBOYOriginal
2016-06-01 13:07:14829browse

常用函数:

  concat 连接函数  Lower 转小写  upper 转大写  Length 长度 substr  子串  now 当前时间  Year 当前年份...

流程函数:

  ifnull(column,result1,result2) 判定字段为空则返回result2,不为空则result1。

  case...when...then...else...end 分支语句。

聚合函数:

  AVG 平均值  sum 求和  MAX 最大值  MIN 最小值  count[distinct] 统计数量,null值不统计,不计数。

where 和 having对比:

  都用作条件限定但having只能用在。

    where           having

  Group by 之前           Group by 之后

  不能使用组合函数   可以使用组合函数

  order by在两者之后使用

Limit结果限定:

  limit 5;检索前5个

  limit5,10;检索6-15个

结构:

  select...

  from...

  where...

  group by...

  having...

  limit...

  order by...

  

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn