我需要更新表historydata并将一些ID放入新列。标识存在于两个单独的表,托盘和pallets_archive中。我该怎么做呢?我使用的是MySQL 6.3。
这就是我所拥有的-
UPDATE hd
SET hd.palletIdx = allPallets.idx
FROM historicdata as hd
INNER JOIN (SELECT idx, palletBarcode FROM pallets UNION ALL
SELECT idx, palletBarcode FROM pallets_archive) as
allPallets ON hd.palletFullCode = allPallets.palletBarcode
但是它一直在抱怨。
答案 0 :(得分:0)
您可以尝试以下吗?
UPDATE hd
INNER JOIN (SELECT idx, palletBarcode FROM pallets UNION ALL
SELECT idx, palletBarcode FROM pallets_archive) as
allPallets ON hd.palletFullCode = allPallets.palletBarcode
SET hd.palletIdx = allPallets.idx