RedShift 中更新语句中的表别名



我有一个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" 

有没有办法在不指定整个表的情况下为表添加别名。

正确的语法是:

更新table_name SET 列 = { 表达式 |默认 } [,...]

[ 来自列表 ]

[ 条件 ]

  • 使用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 

最新更新