gpt4 book ai didi

mysql - 如何将 t2.col2 复制到 t1.col3,其中 mysql 中 t1.col1 = t2.col1?

转载 作者:行者123 更新时间:2023-11-29 11:29:33 26 4
gpt4 key购买 nike

t1 和 t2 是表。 t1 有 3 列,t2 有 2 列。它们在 col1 中具有相同的数据。目前 t1.col3 为空。如何用 t2 中的适当数据填充它?

此查询的结果:

SELECT t1.col1, t1.col2, t2.col2 FROM t1 LEFT JOIN t2 USING (col1);

这正是我想要的 t1。

最佳答案

您可以使用插入选择来实现此目的。

insert into t1 (col3) 
select t2.col2 from t2, t1 where t2.col1 = t2.col1

关于mysql - 如何将 t2.col2 复制到 t1.col3,其中 mysql 中 t1.col1 = t2.col1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37648895/

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