我有一个问题:
SELECT a.id, b.products_id,a.zenid
FROM titles a, ANOTHERDATABASE.products_description b
WHERE b.products_name = a.title
它给出了
id products_id zenid
57 3193 0
81 2037 0
我真正需要的是使用products_id更新zendid,使其成为:
id products_id zenid
57 3193 3193
81 2037 2037
答案 0 :(得分:1)
update a
set a.zenid=b.products_id
from titles a inner join ANOTHERDATABASE.products_description b
on b.products_name = a.title
答案 1 :(得分:1)
这是使用MySQL中的连接更新表的方法:
UPDATE titles a
INNER JOIN ANOTHERDATABASE.products_description b
ON b.products_name = a.title
SET a.zenid = b.products_id