RedShift中update语句中的表别名

时间:2018-10-24 15:50:00

标签: sql sql-update amazon-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" 

是否可以在不指定整个表的情况下别名表?

1 个答案:

答案 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 
相关问题