我有一条sql语句,如下所示,我正尝试将其转换为Redshift。
update #tmpHist l
set spread = lh.spread
from table1 lh
where
l.id=lh.id
但是它给出错误为:
[Amazon](500310) Invalid operation: syntax error at or near "l"
是否可以在不指定整个表的情况下别名表?
答案 0 :(得分:0)
正确的语法是:
UPDATE table_name SET列= {表达式|默认} [,...]
[FROM fromlist]
[哪里有条件]
FROM
子句联接其他表。您可以尝试一下。
update #tmpHist
set spread = lh.spread
from table1 lh
where
#tmpHist.id=lh.id
或者您可以尝试使用update .... join
作为别名。
update l
set spread = lh.spread
from table1 lh join #tmpHist on l.id=lh.id