There is a table consists of the following columns: party_name, party_id , party, party2_id , val1, val2
It is necessary that the two values party_id and party2_id were checked when writing if they already exist (exactly two in the same DB line) when attempting to write, then it is necessary to overwrite the "update" data in this line. Separately, party_id and party2_id can be repeated countless times, but together in the same line they can occur only once, but there can be an option when party_id changes places with party2_id for example:
Line number 1 DB party_id = 1 party2_id = 2
Line number 2 DB party_id = 2 party2_id = 1
In MySQL, I’m a complete novice, before (I don’t remember how) I used the "unique" property via phpmyadmin on one of the columns - and this did not allow me to write duplicates in a column - do I need to do the same actions, or do I have to solve it through base?
Request Code:
query =(""INSERT INTO "" + ""allbase ""+""(party_name, party_id, party, party2_id, val1, val2) VALUES (%s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE party_name=VALUES(party_name), party_id=VALUES(party_id), party=VALUES(party), val1=VALUES(val1), val2=VALUES(val2)"")