【www.gdgbn.com--mysql教程】

mysql教程 concat() 连接字符串详细说明
在有些情况下你想两个或多个字符串,在mysql中有个字符串连接函数concat(),下面我们就讲讲它的使用方法吧。

concat语法
concat(str1,str2,...)

简单实例两个字符串连接

select concat("hello ","world!");

当然你也可以使用表中的字段而不是字符串常量,你可以混合使用它们。让我们看看稍微复杂的例子。假设我们有一个用户表中的姓名和年龄,现在要连接在一起,我们就可以使用select statement uses the concat

select concat(name, " is ", age," years old.") from user;

bill is 28 years old.
mark is 32 years old.
julia is 44 years old.
alex is 52 years old.

本文来源:http://www.gdgbn.com/shujuku/28003/