mysql的几种函数整理

来源:互联网 发布:新时空软件 编辑:程序博客网 时间:2024/06/03 11:52

1.concat()函数

使用语法:CONCAT(str1,str2,…)  

返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回值为 NULL。

e.g

select  concat(id,name) from user where id=1;

查询结果:1user1

注:如果name为null,则查询结果为null;

2.group_concat()函数

使用语法:group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符']) 

e.g

select group_concat(id) from user where email is null;

查询结果:1,5,8,12,13

3.pow()/power(X,Y)函数

这两个函数返回X的Y次方。

e.g

select  power(5,2);

查询结果为25;


0 0