Oracle数据库中SQL语句进行字符串拼接

一、使用“||”连接

SELECT user_name,'中文名:'|| china_name as "name" FROM "SYS_USER" where id=2089

结果

 二、使用CONCAT()函数连接

SELECT user_name,concat('中文名:', china_name) as "name" FROM "SYS_USER" where id=2078

结果

 在使用这个函数时,当拼接的值不是字符串时,oracle会自动转换成字符串。

需要注意的时,此函数里面只支持两个参数,不支持超过两个的参数,否则会报错。当需要多个参数进行拼接时,可以使用多个concat()函数进行嵌套

SELECT user_name,concat(concat(concat('中文名:', china_name),ENTERPRISE_ID),email) as "介绍" FROM "SYS_USER" where id=2027

结果

 注意:mysql中不能使用||来连接字符串,只能用concat来连接

<if test="channelType!=null and channelType!=''">
                    AND t1.channel_type LIKE concat('%',#{channelType},'%')
                </if>
原文地址:https://www.cnblogs.com/zwh0910/p/14734168.html