SQL错误:ORA-00933:SQL命令未正确结束:Postgres到oracle语法

时间:2013-02-02 04:40:34

标签: sql database oracle postgresql

我收到以下语句的SQL错误ORA-00933。这在postgres中解析,但在oracle中没有解析...如何为oracle格式化?

提前致谢!

UPDATE comments 
SET parent_type='report' 
FROM reports 
WHERE comments.parent_id=reports.id;

1 个答案:

答案 0 :(得分:4)

尝试使用Oracle:

UPDATE Comments
SET parent_type = 'report'
WHERE parent_id IN (SELECT Id FROM Reports)

或者,如果您尝试将值设置为等于另一列中的值:

UPDATE Comments
SET parent_type = (SELECT FieldName
                   FROM reports
                   WHERE reports.id = Comments.parent_id);

这适用于MSSQL:

UPDATE c
SET c.parent_type='report' 
FROM Comments c JOIN reports r ON c.parent_id=r.id
祝你好运。