Tell me how you can write a query so that when changing the source or object, he first wrote -1 and then wrote +1.
I have a request to add, it compares and if something is different somewhere, it adds. To this table .
Here is the request:
INSERT INTO chronol (source, object, redirect, serial_number, model)
(SELECT id, date, source, object, redirect, serial_number, model
FROM chronol_2
EXCEPT SELECT id, date, source, object, redirect, serial_number, model
FROM chronol_1);
All data and queries + result ---> https://dbfiddle.uk/p-c0Ixeh
But I need to write the condition so that he first wrote the information with -1 and then added the information + 1, it always adds + 1 and it is necessary that it was -1 before it. It looks like the history of accounts is first inisuetsya and then added somewhere.
Sorry, it's very difficult to formulate, because I don't know how to do it correctly. I will write the criteria and additional information in the comments. Strictly do not judge