MySQL -Update, wenn existiert sonst einfügen
INSERT INTO tableName(id, NAME, score)
VALUES(1, "Fadl", 285)
ON DUPLICATE KEY
UPDATE NAME = "Fadl", score = 285
FADL
INSERT INTO tableName(id, NAME, score)
VALUES(1, "Fadl", 285)
ON DUPLICATE KEY
UPDATE NAME = "Fadl", score = 285
INSERT INTO table (column_list)
VALUES (value_list)
ON DUPLICATE KEY UPDATE
c1 = v1,
c2 = v2,
...;
I am amazed to see so many useless codes and answers...
Just replace INSERT with REPLACE.
¯\\_(ツ)_/¯
INSERT INTO user(id, name, address)
VALUES(1, "Fadl", 285)
ON DUPLICATE KEY
UPDATE name = "Fadl", address = 285