我有两个表: NewData 和 RecentData
NewData
id | Order_Number | Company | SerialNumber | ShipDate
-----------------------------------------------------
1 | 2323 | Apple | SN2324 | 2018-09-12 00:00:00
2 | 53444 | Telsa | SN9098 | 2018-09-12 00:00:00
3 | 42321 | Stack | SN9999 | 2018-09-12 00:00:00
RecentData
id | Order_Number | Company | SerialNumber | ShipDate
-----------------------------------------
1 | 2323 | Apple | | 2018-05-05 00:00:00
2 | 53444 | Telsa | oldserial | 2018-07-20 00:00:00
在 NewData 表上更改 ShipDate 后,我只需要 update ShipDate 和<最近数据表上的em> SerialNumber 列。另外,如果在NewData表上确实存在Order_Number,而在LatestData表上却存在DOESNT,则将整行添加到LatestData表中。
我尝试了以下操作:
UPDATE RecentData
LEFT JOIN NewData on NewData.Order_Number = RecentData.Order_Number
SET RecentData.Order_Number = NewData.Order_Number;
但这会删除Order_Number列中的订单号。
请帮助!