lundi 23 avril 2018

UPDATE statement only when score > current score

I'm trying to create an update statement in a query which is executed in PHP. Although I don't have much PHP experience, I tried it.

this is what I have now:

$query = "INSERT INTO scores VALUES ('$uid', '$name', '$score') ON DUPLICATE KEY UPDATE 'score' = '$score';";

how do I create an if-statement in this? I tried this already:

$query = "INSERT INTO scores VALUES ('$uid', '$name', '$score') ON DUPLICATE KEY UPDATE 'score' = if('$score' > 'score', '$score', 'score');";

Aucun commentaire:

Enregistrer un commentaire