gpt4 book ai didi

google-bigquery 使用另一个表更新表

转载 作者:行者123 更新时间:2023-12-04 12:44:05 28 4
gpt4 key购买 nike

嗨,我在 BigQuery 中有两个表:

表A:消费者ID,消费者分割

表B:消费者ID

我想要做的就是用“找到”更新 TableA.consumerSegment,其中 TableA.consumerID=TableB.consumerID

我正在使用此语句,但作为返回,我收到一个错误:

UPDATE `MyTableLongNameA` AS TableA

SET TableA.consumerSegment = "Found"

FROM `MyTableLongNameB` AS TableB

WHERE TableA.consumerID = TableB.ConsumerID

错误是:

Scalar subquery produced more than one element



任何帮助表示赞赏。

谢谢

最佳答案

这表明 TableB 中存在多个匹配项获取来自 TableA 的 key .来自 the documentation :

If a row in the table to be updated joins with exactly one row from the FROM clause, then the row is updated.

If a row in the table to be updated joins with more than one row from FROM clause, then the query generates a runtime error.



试试这个:
UPDATE `MyTableLongNameA` AS TableA
SET TableA.consumerSegment = "Found"
WHERE EXISTS (
SELECT 1
FROM `MyTableLongNameB` AS TableB
WHERE TableA.consumerID = TableB.ConsumerID
)

关于google-bigquery 使用另一个表更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49871793/

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