dbpQuery: Adding new record to table - Forum

Forum Navigation
You need to log in to create posts and topics.

dbpQuery: Adding new record to table

Can anyone point me to where to find the answer to my problem.

I want to be able to copy new records from on table to another and not to delete the data and copying it again.

ie: if I add 30 records, it only copies the selected fields from  these records, to make the Master index.

Regards

Michael

 

dbpQuery "GOON" "MASTER" "CAT = [#34]GRO Index[#34]"

If "[GOON.MASTER.$RecCount]" "=" "0"

  dbpExecSQL "GOON" "INSERT INTO Master|SELECT AFN_R,CAT,SUBCAT,SURN,Givn,EDATE FROM GRO;" ""

Else

  MessageBox "Delete" "Delete all found records?" "Yes?No" "[Result]"

  If "[Result]" "=" "1"

  EndIf

EndIf

 

Well found the Answer, after a long trial and Error

INSERT INTO target_table (AFN_R, Cat, SubCat, Surn, Givn, EDate)
SELECT AFN_R, Cat, SubCat, Surn, Givn, EDate
FROM source_table
WHERE NOT EXISTS (
    SELECT 1 
    FROM target_table 
    WHERE target_table.AFN_R = source_table.AFN_R
);

 

alangonzalez91 has reacted to this post.
alangonzalez91