gpt4 book ai didi

mysql - sql insert id of row into a string in update 语句

转载 作者:行者123 更新时间:2023-11-29 00:46:50 25 4
gpt4 key购买 nike

我如何在 mysql 5.5 中执行此操作?正在考虑 concat,但我认为有更简单的方法。

id  content
1
2

update posts set content='here is content ' + this.id

这样:

id content 
1 here is content 1
2 here is content 2

谢谢

最佳答案

这就是你需要的:

update posts
set content=CONCAT('here is content ', CAST(id as CHARACTER))

这是一个link在 SQLFiddle 上进行测试。

关于mysql - sql insert id of row into a string in update 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10220159/

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