I have doubt to mount a query to update and / or add data in a table.
I have a table1 that will be supplied with the following rules:
The table1 have the same fields of table2 + status field to show if the register is active ("A") or inactive ("I").
For each record in table1, check if there are new records in table2
If the record exists in table2 and the record doens't exist in table1, includes the information in table 1 - all the fields of that record from table2 + character "A" (active) in the status field.
If the record exists in table2 and the record exists in table1 too, I have to compare id_register from table2 with the id_register from table1
If any data in this row is different, I have to insert a new row in table1 - all fields from the table2 + character "A" (active) in the status field -, AND the line that was different in table1 will be update with a character "I" (inactive) in status field;
If the record was deleted in table2, this row will receive character "I" (inactive) in table1 status field. (Deleted Record = I have to verify the records that exists in table1 and doens't exists in table2)
The records that have no changed will not be updated.
The tables:
table1
id_register name address phone email date value status
table2
id_register name address phone email date value
Thank you!