0

I have the follwowing query:

UPDATE o
SET o.supervisor  = e.supervisor
FROM orders o
INNER JOIN employees e on e.employee_id = e.employee_id
WHERE o.supervisor IS NULL;

The query is supposed to update the table orders when there is a null value in the column supervisor using the data from the table employees.

When I run this query (on DB visualizer), i get this error: ORA-00933: SQL-Befehl wurde nicht korrekt beendet, what is german for

ORA-00933: SQL-command wasn't terminated correctly

What is my mistake?

forpas
  • 145,388
  • 9
  • 31
  • 69
stefanR
  • 67
  • 5

1 Answers1

0

Oracle does not support FROM in an UPDATE. You can use a subquery instead:

UPDATE orders o
    SET o.supervisor =
            (SELECT e.supervisor
             FROM employees e 
             WHERE e.employee_id = o.employee_id
            )
    WHERE o.supervisor IS NULL;

Note that your JOIN clause is wrong anyway, because it refers to only one table.

Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709