[英]Table aliasing in update statement in RedShift
I have a sql statement which is as follows which I am trying to convert to Redshift.我有一个 sql 语句,如下所示,我正在尝试将其转换为 Redshift。
update #tmpHist l
set spread = lh.spread
from table1 lh
where
l.id=lh.id
But it gives error as:但它给出的错误为:
[Amazon](500310) Invalid operation: syntax error at or near "l"
Is there a way to alias table without specifying entire table.有没有办法在不指定整个表的情况下对表进行别名。
The correct syntax is:正确的语法是:
UPDATE table_name SET column = { expression | UPDATE table_name SET column = { 表达式 | DEFAULT } [,...]默认 } [,...]
[ FROM fromlist ] [来自列表]
[ WHERE condition ] [ WHERE 条件 ]
FROM
clause to join in additional tables.使用FROM
子句加入附加表。You can try this.你可以试试这个。
update #tmpHist
set spread = lh.spread
from table1 lh
where
#tmpHist.id=lh.id
or you can try to use update .... join
for alias name.或者您可以尝试使用update .... join
作为别名。
update l
set spread = lh.spread
from table1 lh join #tmpHist on l.id=lh.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.