What are peoples’ thoughts on the most performance efficient way to do the following query:
-
3 column table
-
if the combination of
col_1andcol_2values already existUPDATE col_3 -
else
INSERTnew row
I assume i need some kind if UPDATE ON DUPLICATE KEY (which i’ve never used before), however I do not have a ‘KEY’ but instead a pair of two values (columns) to make a key…
You can create a
PRIMARYorUNIQUEkey out of multiple columns (called a composite key) in MySQL, which’ll allowON DUPLICATE KEYto work just fine.