我有表 t1。
table t1
id post_id tags
1 null a
2 1 null
3 1 null
4 null b
我想更新 post_id = id 的标签。我尝试了一个查询,它给了我零输出。
当标签存在时,post_id 始终为空,当存在 post_id 时,标签始终为空
update t1 set tags = tags where post_id = id;
你们可以为我正确地构图吗?请帮我
update t1 a join t1 b on a.id = b.post_id set b.tag = a.tag
update t1 set tags = tags where post_id = id;
此处不会更新任何记录,因为 tags = tags您正在使用该列值更新该列。
update t1 set tags = tags where post_id = id;
这意味着设置 A=A, 1=1, B=B, 给自己设置一些东西。那不会更新任何东西。您必须提供不同的值来更新它,例如
update t1 set tags = "Testing 123" where post_id = id;