如何在Redshift中使用此值更新此表:
UPDATE t1
SET col1 = 'new_value_here'
FROM t1
LEFT JOIN t2
on t1.col2 = t2.col2
WHERE
t1.country IN ('USA','JAPAN')
AND t1.col1 = 'old_value_here'
AND t2.col2 IS NULL;
我收到错误消息:“目标表必须是等值谓词的一部分;”
如何在Redshift中使用此值更新此表:
UPDATE t1
SET col1 = 'new_value_here'
FROM t1
LEFT JOIN t2
on t1.col2 = t2.col2
WHERE
t1.country IN ('USA','JAPAN')
AND t1.col1 = 'old_value_here'
AND t2.col2 IS NULL;
我收到错误消息:“目标表必须是等值谓词的一部分;”
Redshift在UPDATE查询的FROM子句中不允许任何外部联接。您需要将其用作子查询或重新编写逻辑。
这是我对您的查询所做的操作,但是由于您对数据有更好的了解,您可能希望以自己的方式编写它。
UPDATE t1
SET col1 = 'new_value_here'
from (select t1.col2 as t1_col2,t2.col2 as t2_col2
from t1 left join t2 on t1.col2=t2.col2) t1t2
WHERE t1t2.t1_col2=t1.col2
and t1t2.t2_col2 is null
and t1.country IN ('USA','JAPAN')
AND t1.col1 = 'old_value_here';