I am trying to use an SQL query in Postgres that looks like this:
UPDATE gamebet
SET points = 15
WHERE game = 8
AND "scoreT1" > "scoreT2"
AND "scoreT1" - "scoreT2" != 1
AND ("scoreT1" != 1 AND "scoreT2" != 0)
It should update the scores of some bets where scoreT1 is bigger than scoreT2, but there are some rows that should not be updated. And that is when scoreT1 - scoreT2 = 1 And if both scoreT1 = 1 and scoreT2 = 0, but it should only apply if both of these conditions are met. And somehow the parenthesis are not applied. Since e.g. this record is not modified:
scoreT1 = 3
scoreT2 = 0
This record should be updated, but since one of the conditions is scoreT2 != 0
it is not updated. How can I group the last conditions that they need to be met together?