根据另一个表中的列更新表

编程入门 行业动态 更新时间:2024-10-10 19:23:53
本文介绍了根据另一个表中的列更新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 UPDATE bad_table,good_table SET bad_table.post_content = good_table.post_content WHERE bad_table.post_type = 'post' AND bad_table.post_date = good_table.post_date

这是我的代码,用于根据日期值将一整列从一个表移到另一个表,我发现这在这种情况下是独一无二的.然而,我一无所获.

This is my code for getting one whole column from one table to another, based on a date value, which I found is unique for this case. However, I get nothing.

如果我选择这个,就像这样:

If I select this, like so:

SELECT * FROM bad_table,good_table WHERE bad_table.post_type = 'post' AND bad_table.post_date = good_table.post_date

...我得到了我期望的所有行.我做错了什么?

...I get all the rows I would expect. What am I doing wrong?

推荐答案

假设 good_table 中可能有多个不是帖子的条目,您需要细化您的加入条件以仅选择帖子"

Assuming there could be multiple entries in good_table that are not posts, you need to refine your join condition to only select 'posts'

update bad_table inner join good_table on bad_table.post_date = good_table.post_date and bad_table.post_type = good_table.post_type set bad_table.post_content = good_table.post_content where bad_table.post_type = 'post'

更多推荐

根据另一个表中的列更新表

本文发布于:2023-07-09 21:11:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!