gpt4 book ai didi

mysql - 如何在 mysql 的同一列上使用 LEFT 和 REPLACE?

转载 作者:行者123 更新时间:2023-11-29 16:06:05 26 4
gpt4 key购买 nike

我想选择一列并删除(用空格替换)任何换行符或回车符,并且我只想在替换后获取该列中的前 40 个字符。

这是我尝试过的查询,但我得到了

select date, REPLACE(LEFT(message, '\r', ' '), 30)
from table1
where message like 'testing%'

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' ' '), 30) from events_cleared where message like 'testing%' ' at line 1

最佳答案

您的参数顺序不正确(您已将 REPLACE 参数传递给 LEFT)。试试这个:

select date, REPLACE(LEFT(message, 30), '\r', ' ')
from table1
where message like 'testing%'

关于mysql - 如何在 mysql 的同一列上使用 LEFT 和 REPLACE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55737402/

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