mysql常用函数 电脑版发表于:2020/8/26 13:07 一:mysql常用函数; 1. ifnull(); 语法:select math + ifnull(english,0) from students ; //如果english为null,则替换成0。null参与计算,结果都为null; 2. count(); 查询学生表中有多少条记录 语法:select count(列名)from 表名;//如果某条记录中有null,则不能使用为null的列名作为参数,null不参与计算。 3.max();语法:select max(列名)from 表名; 4.min();语法 select min(列名)from 表名; 5.sum(); 6.avg(); 二,模糊查询, 关键字like; 语法 : select * from 表名 where 列名 like ' '; 查询班上姓李的同学。SELECT *from students where name LIKE "李%"; 查询班上名字包含“德”字的同学。SELECT *from students where name LIKE "%德%"; 查询名字的第二个字为“三”的同学;SELECT *from students where name LIKE "_三%"; 查询名字为三个字的同学:SELECT *from students where name LIKE "___"; "-":在模糊查询里代表一个字符; "%":代表任意个字符;