How can I give MySql a INSERT
or a UPDATE
if the line in question already exists or not?
I tried the following but it did not work:
IF EXISTS (SELECT * FROM configs WHERE id_serie = :id)
UPDATE configs
SET dados = :valor
WHERE id_serie = :id
ELSE
INSERT INTO configs (id_serie, dados) VALUES (:id, :valor)
But it did not work, I read about ON DUPLICATE KEY UPDATE
but since the column I use to check in id_serie
is not the primary key of the table, I figured it would not work, or does it work?