gpt4 book ai didi

mysql - 从 2 行替换

转载 作者:行者123 更新时间:2023-11-29 04:40:27 26 4
gpt4 key购买 nike

我正在尝试替换下面的文字

<div>
&nbsp;</div>
<div>
&nbsp;</div>

成为

<div></div>

我用过下面的

update `mytable` set post_content = REPLACE(post_content, '<div>\n' & CHAR(9) & '&nbsp;</div>\n<div>\n' & CHAR(9) & '&nbsp;</div>', '<div></div>')

低于错误

 #1292 - Truncated incorrect INTEGER value: '<div> '

最佳答案

不要使用和号。那就是按位与运算符(请参阅:https://dev.mysql.com/doc/refman/5.0/en/bit-functions.html#operator_bitwise-and),它将返回一个无符号整数。

使用 concat()(参见:https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat)。

update `mytable` 
set post_content = REPLACE(post_content,
concat('<div>\n\t','&nbsp;</div>\n<div>\n\t','&nbsp;</div>'),
'<div></div>');

它将连接所有参数并采用以下形式:

concat(str1, str2, ...)

关于mysql - 从 2 行替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30303136/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com