Solved Insert record from table to table one by one

zezo2021

Member
Local time
Today, 18:48
Joined
Mar 25, 2021
Messages
415
hello friends

Have a great day

explaining my problem in excel attached

==========================
if an entire row duplicated
Not included version
==========================


Thank you so much in advance
 

Attachments

Last edited:
One by one with MsgBox? At 986 Records you would have a lot of fun clicking.

Actually, you settle the case with two queries that do the right thing about everything, message-free.

Step 1: Update the existing records. Example query with 2 fields, which in combination form the characteristic for duplicate:
SQL:
UPDATE
    TargetTable AS Z
        INNER JOIN SourceTable AS Q
        ON Q.Key1 = Z.Key1
        AND Q.Key2 = Z.Key2
SET
    Z.Value1 = Z.Value1 + Q.Value1,
    Z.Date_Edited = Now()

Step 2: Adding only new records:
SQL:
INSERT INTO
    TargetTable(
        Key1,
        Key2,
        Value1,
        Date_Created
    )
SELECT
    Q.Key1,
    Q.Key2,
    Q.Value1,
    Now()
FROM
    SourceTable AS Q
        LEFT JOIN TargetTable AS Z
        ON Q.Key1 = Z.Key1
            AND
        Q.Key2 = Z.Key2
WHERE
    Z.Key1 Is Null

You can use the time stamp in the Date_Edited and Date_Created fields to filter and display the records concerned in a selection query.
 

Users who are viewing this thread

Back
Top Bottom