jeudi 21 juillet 2016

How to update a column for two separated ids?

I have these two queries:

$dbh
->prepare("UPDATE user
            SET reputation = reputation - 15
            WHERE id = ?")
->execute(array($old_author));

$dbh
->prepare("UPDATE user
            SET reputation = reputation + 15
            WHERE id = ?")
->execute(array($new_author));

I want to know can I do that by one single query? I mean can I both - 15 and + 15 in reputation column for two users in the same query?

Aucun commentaire:

Enregistrer un commentaire