gpt4 book ai didi

mysql插入id比较两个表

转载 作者:行者123 更新时间:2023-11-29 07:39:01 25 4
gpt4 key购买 nike

我有两张表: enter image description here

我想将 table1 中的 post_id 插入 table2 中的 media_id ,其中两个表中的字段 meta_value 相同。有办法做到这一点吗?

最佳答案

是的,您可以使用 update with join 来做到这一点

update table2 t2
join table1 t1 on t1.meta_value = t2.meta_value
set t2.media_id = t1.post_id

如果您想针对特定的meta_value执行此操作,您可以在末尾添加一个where条件

where t2.meta_value = '{your value}'

关于mysql插入id比较两个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29630137/

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