我有桌子t1。
table t1
id post_id tags
1 null a
2 1 null
3 1 null
4 null b
我想更新post_id = id的标签。 我尝试了一个查询,它给了我零输出。
当标签存在时,post_id始终为null,而当post_id存在时,标签始终为null
update t1 set tags = tags where post_id = id;
你们可以为我准备好吗?请帮帮我
答案 0 :(得分:2)
update t1 a join t1 b on a.id = b.post_id set b.tag = a.tag
答案 1 :(得分:0)
update t1 set tags = tags where post_id = id;
此处不会更新任何记录,因为tags = tags
。您正在使用该列值更新列。
答案 2 :(得分:0)
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;