在PostgreSQL上运行时,此UPDATE语句有效,但在H2上运行时,则失败。 什么是等效的H2语句?

UPDATE award_details SET award_id = a.id FROM awards a WHERE a.award_details_id = award_details.id; 

H2错误消息是:

SQL State  : 42000 Error Code : 42000 Message    : Syntax error in SQL statement "​​[*] UPDATE AWARD_DETAILS SET AWARD_ID = A.ID FROM AWARDS A WHERE A.AWARD_DETAILS_ID = AWARD_DETAILS.ID"; SQL statement: 

===============>>#1 票数:1 已采纳

您当前的更新语法看起来是Postgres风格。 而是使用相关子查询更新语法:

UPDATE award_details aw SET award_id = (SELECT a.id FROM awards a WHERE a.award_details_id = aw.id); 

  ask by Dónal translate from so

本文未有回复,本站智能推荐: