mysql 常用函数
1.IFNULL(expr1,expr2),含义是:如果第一个参数不为空,则返回第一个参数,否则返回第二个参数. 类似于Oracle中的NVL函数
2.IF(expr1,expr2,expr3 )含义是:如果第一个表达式的值为TRUE(不为0或null),则返回第二个参数的值,否则返回第三个参数的值。类似于Oracle中的NVL2函数
持续更新中...
3.distinct 去重 可以单个字段 去重 ,也可以多个字段 去重 多个字段 去重必须全部相同 ,不能指定字段去重
select distinct name from table_name; select distinct name, age from table_name; name 和 age 必须全部相同
select name ,distinct age from table_name ; 不行
3.union 合并 两个结果为一个结果 并且和去重 union all 不去重
select col1 ,col2, col3 from table_name1
union / union all
select col1, col2, col3 from table_name2;
规则 col 个数相同 类型相同 顺序相同 如列名不同 可以使用as 不同则以union前的table名为主
4.concat (str1,str2,str3.....) 字符串拼接
5.upper() 转 大写 lower() 转小写
6. 字段 字符操作 https://www.cnblogs.com/winter-bamboo/p/10779466.html https://blog.csdn.net/qq_33730348/article/details/79865553
7.