gpt4 book ai didi

sql - 为什么这个 sql 更新查询不起作用?

转载 作者:行者123 更新时间:2023-12-04 06:52:39 26 4
gpt4 key购买 nike

我有一个表,里面有 5,000(table1) 行。目前,其中 3,000 个已填满数据。其余值当前为空。在单独的表(table2)中,我有剩余的 2,000 行数据。我只是试图将 table2 中的值放入 table1,但此语句不起作用:

Update table1
Set field1 = (Select field1
From table2
Where table1.id = table2.id)
Where Exists(Select field1
From table2
Where table1.id = table2.id)

看起来这应该可以正常工作,但是我从 Base 收到错误,我正在使用的数据库程序只是说错误 Near "": syntax error...any help??谢谢!

最佳答案

您可以尝试通过连接来实现。我习惯在 T-SQL 中这样做,但我相信语法将相同或非常相似。

Update Table1
JOIN Table2 ON Table1.id = Table2.id
SET Table1.value = Table2.value

关于sql - 为什么这个 sql 更新查询不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2901300/

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