我必须从另一个表更新一个表: 我可以使用MySQL sgbd进行更新:
update product pr , provider p
set pr.provider_name = p.name
where p.provider_id = pr.provider_id ;
但是当我尝试用oracle做的时候: 我为oracle
尝试了这个查询UPDATE pr
SET pr.provider_name = p.name
FROM product pr
INNER JOIN provider p ON p.provider_id = pr.provider_id ;
我收到此错误:
Error Code: 933, SQL State: 42000] ORA-00933: SQL command not properly ended
我的查询有什么问题?
答案 0 :(得分:2)
请改为尝试:
UPDATE product
SET provider_name = (
SELECT p.name
FROM provider p
WHERE p.provider_id = product.provider_id
);
答案 1 :(得分:2)
UPDATE product prod SET prod.provider_name = (SELECT prov.name
FROM provider prov
WHERE prod.provider_id = prov.provider_id)