在庫にあるスプロケットの物理的な質量を追跡するテーブルがあります。
create table sprockets(
id NUMBER,
mass NUMBER
);
INSERT into sprockets VALUES (1, 4);
INSERT into sprockets VALUES (2, 8);
INSERT into sprockets VALUES (3, 15);
INSERT into sprockets VALUES (4, 16);
INSERT into sprockets VALUES (5, 23);
INSERT into sprockets VALUES (6, 42);
私はスプロケットのメカニックを使用して、スプロケットの定期的なメンテナンスを行っています。それらの変更によってスプロケットの質量が変化した場合は、メンテナンスレポートにその旨を記録します。
create table maintenance_events(
sprocket_id NUMBER,
new_mass NUMBER
);
--chipped a widget off of sprocket #1; mass reduced to 3 kg
INSERT into maintenance_events VALUES (1, 3);
--new lead bearings makes sprocket #2 weigh 413 kg
INSERT into maintenance_events VALUES (2, 413);
sprockets
各スプロケットの現在の質量でテーブルを最新の状態に保ちたいです。を取り込んで、の古い値を上書きnew_mass
したい。この質問の上位2つの回答を参照しましたが、どちらもエラーになります。maintenance_events
mass
sprockets
UPDATE sprockets
set mass = maintenance_events.new_mass
from sprockets, maintenance_events
where sprockets.id = maintenance_events.sprocket_id
Error at Command Line:2 Column:38
Error report:
SQL Error: ORA-00933: SQL command not properly ended
UPDATE sprockets
set sprockets.mass = maintenance_events.new_mass
from sprockets
INNER JOIN maintenance_events
on sprockets.id = maintenance_events.sprocket_id
Error at Command Line:2 Column:48
Error report:
SQL Error: ORA-00933: SQL command not properly ended
私は何が間違っているのですか?