I want to select fields in a record of a table and update just one of these fields. How can I do?
I try this:
SELECT v.idvideo, v.title
FROM video v WHERE v.schedulingflag IS FALSE AND v.errorflag IS FALSE
ORDER BY v.idvideo LIMIT 1 FOR UPDATE ;
UPDATE video SET schedulingflag = true;
But in this way it sets field "schedulingflag" true in all record!
The
SELECT FOR UPDATEsyntax tells PG that you’re going to be updating those records and locks them against concurrent access. However you still need to issue the appropriateUPDATEcall to change the particular records you’ve locked.In this case, just use the same
WHEREclause in yourUPDATE, e.g: