1 概述
2 方法
2.1 concat()
/*
1.语法:concat(str1, str2, ...)
2.说明:若字符串中出现 null,会直接返回 null
*/
select concat('a', 'b') t1,
concat('a', 'b', '') t2,
concat('a', 'b' , null) t3
from dual;
执行结果:
t1 t2 t3
ab ab
2.2 concat_ws()
/*
1.语法:concat_ws(separator,str1,str2,…)
2.说明:若字符串中出现 null,会忽略 null
3.特别:可指定分隔符 separator
*/
select concat_ws(',', 'a', 'b') t1,
concat_ws(',', 'a', 'b', '') t2,
concat_ws(',', 'a', 'b' , null) t3
from dual;
执行结果:
t1 t2 t3
a,b a,b, a,b