mysql中的concat用法!

mysql中的concat用法!,第1张

这个sql语句是指从数据库表里面拼接组合goods_sn,goods_title,goods_brief,goods_name 有包含tablet字段的数据。等价于goods_sn||goods_title||goods_brief||goods_name LIKE '%tablet%。

concat 等同于字符串连接符 ||,concat(字串1, 字串2, 字串3, ...),将字串1、字串2、字串3,等字串连在一起。

扩展资料:

MySQL,Oracle,SQL Server拼接字符串查询示例:

例子1:

MySQL:

SELECT CONCAT(region_name,store_name) FROM Geography  WHERE store_name = 'Boston'

例子2:

Oracle:

SELECT region_name || ' ' || store_name FROM Geography  WHERE store_name = 'Boston'

例子3:

SQL Server:

SELECT region_name + ' ' + store_name FROM Geography WHERE store_name = 'Boston'

参考资料:MySQL字符串连接CONCAT()函数_W3Cschool

用法:字符串拼接:

m.table_Name like concat(concat('%',#{tableName}),'%')----------------------就是拼接成% 变量值%

select * from m where m.name like concat(concat('%','#tableName'),'%');

1、去掉mysql数据库中某字段的换行符和回车符:replace函数UPDATE student SET name = REPLACE(REPLACE(title,CHAR(10),''),CHAR(13),'') WHERE ID = xxxxxx注解:CHAR(10),'':将换行符CHAR(10)替换成空串,可理解为删除换行符CHAR(13),'':将回车符CHAR(13)替换成空串,可理解为删除回车符2、往mysql某个字段中插入换行符和回车符:concat函数concat函数可以连接一个或者多个字符串,若其中一个为null,则返回nullUPDATE student SET name = concat('字符串1',CHAR(10),CHAR(13),'字符串2') WHERE ID = xxxxx注解:这样就将 字符串1 和 换行符 和 回车符 和字符串2 拼接在一起了后记:查询某个字段是否含有换行符和回车符select *from student where name like '% \n\r %'


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7403070.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存