连接列值 mysql CONCAT函数

时间:2022-11-13 15:51:06

   mysql concat(str1,str2,...)

  返回结果为连接参数产生的字符串,如果任何一个参数带有null,则返回结果为null.如果所有参数均为非二进制字符串,则结果为非二进制字符串。 如果自变量中含有任一二进制字符串,则结果为一个二进制字符串。一个数字参数被转化为与之相等的二进制字符串格式;若要避免这种情况,可使用显式类型 cast, 例如: SELECT CONCAT(CAST(int_col AS CHAR), char_col);

  

select concat(ename, ' WORKS AS A ',job ) as msg from emp where  deptno =10;

  返回结果

+---------------------------+
| msg                       |
+---------------------------+
| CLARK WORKS AS A MANAGER  |
| KING WORKS AS A PRESIDENT |
| MILLER WORKS AS A CLERK   |
+---------------------------+
3 rows in set