美文网首页
MySQL常用函数

MySQL常用函数

作者: 5号船长 | 来源:发表于2018-12-29 14:02 被阅读10次

max() 函数

max()函数返回所选列的最大值
select max(column_name) from table_name

min() 函数

min() 函数返回所选列的最小值
select min(column_name) from table_name

count() 函数

count() 函数返回指定条件的行数
select count(column_name) from table_name where condition

count() 与 distinct 结合使用

count(distinct column_name) 函数返回指定列的不同值的树木
select count(distinct column_name) from table_name

avg() 函数

avg() 函数返回数字列的平均值
select avg(column_name) from table_name where condition

sum() 函数

sum() 函数返回数字列的总和
select sum(column_name) from table_name where condition

SQL 日期函数


field() 函数

获取第一条记录

MySQL
select subject_id from qsb_test_list order by subject_id asc limit 1

group by 语句

group by 语句通常与集合函数 (count , max , min , sum , avg)一起使用,以按一个或多个列对结果集进行分组
select column_name from table_name group by column_name

having 子句

相关文章

  • MySQL 常用函数

    MySQL 常用函数 GROUP_CONCAT() 函数 CONCAT() 函数

  • 7、mysql常用函数

    7、mysql常用函数 7.1、IF函数 7.2、IFNULL函数 7.3、NULLIF 函数 7.4、CASE ...

  • Mysql常用函数

    ~~lpad(),rpad(): 字符长度填充: lpad(str,len,padstr) select LPAD...

  • mysql常用函数

    Conv(n,from_base,to_base) 对数字n进行进制转换并以字符串格式返回,from_base是原...

  • MySql常用函数

    本文引用燕归来http://www.zhoutao123.com/?p=99 字符串处理函数 字符串链接函数 可以...

  • MySQL常用函数

    字符串相关函数 1ASCII(String) 返回字符串第一个字母的ASCII码: SELECT ASCII('A...

  • MySQL 常用函数

    在 MySQL 数据库中,函数可以用在 SELECT 语句及其子句(例如 where、order by、havin...

  • MySQL 常用函数

    RAND() 函数 MySQL RAND() 函数可以被调用,产生一个在 0 和 1 之间的浮点数 当使用整数作为...

  • MySQL常用函数

    1.Concat(s1,s2...sn)函数:把传入的参数链接为一个字符串2.Insert(str,x,y,ins...

  • MySQL常用函数

    一、数学函数 ABS(x) 返回x的绝对值 BIN(x) 返回x的二进制(OCT返回八进制,HEX返回十六进制) ...

网友评论

      本文标题:MySQL常用函数

      本文链接:https://www.haomeiwen.com/subject/wzprlqtx.html