Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用产品代码匹配的另一个数据库中的价格(不是主键)更新一个数据库中的所有价格,同时保持其他字段列不变。
INSERT INTO inventory SELECT * FROM temporary_table ON DUPLICATE KEY UPDATE price = VALUES(price)
这只是复制代码匹配的整个产品
提前致谢
尝试使用替换而不是插入。从库存表中选择除要更新的列之外的所有列(价格)
REPLACE INTO inventory SELECT b.col1, b.col2......... a.price FROM temporary_table a, inventory b where a.product_code = b.product_code