Question : Append / Update Query

What does "this" my current code do? It appears to just replace one table with another.

INSERT INTO SHIPMENT
SELECT SHIPMENTTMMI.*
FROM SHIPMENTTMMI
WHERE (((SHIPMENTTMMI.NAMC)="TMMI"));

What I need it to do is.....
Take the data that is located in SHIPMENTTMMI and Append it to the SHIPMENT table only if the primary key exist in both tables. This is updated "latest" information. I dont need the data to be removed from the SHIPMENT table. (Which is what it is doing now)

Primary Key = ScrapRecordTag

What query do I need?

I need all of the following fields to be updated from SHIPMENTTMMI to SHIPMENT
QPRQPINumber
TagNumber
NAMC
FaultType
ScrapRecordTag [primary key]
Carrier
Description
PCRNumber
Date
TrackingNumber
Type

Answer : Append / Update Query



update SHIPMENT
inner join SHIPMENTTMMI on SHIPMENTTMMI.ScrapRecordTag= SHIPMENT.ScrapRecordTag
set SHIPMENT.QPRQPINumber=SHIPMENTTMMI.QPRQPINumber
,SHIPMENT.TagNumber=SHIPMENTTMMI.TagNumber
,SHIPMENT.NAMC=NAMC
,SHIPMENT.FaultType=SHIPMENTTMMI.FaultType
,SHIPMENT.Carrier=SHIPMENTTMMI.Carrier
,SHIPMENT.Description=SHIPMENTTMMI.Description
,SHIPMENT.PCRNumber=SHIPMENTTMMI.PCRNumber
,SHIPMENT.Date=SHIPMENTTMMI.Date
,SHIPMENT.TrackingNumber=SHIPMENTTMMI.TrackingNumber
,SHIPMENT.Type=SHIPMENTTMMI.Type


Random Solutions  
 
programming4us programming4us