0

How can I add multiple constraints after the WHERE part of the UPDATE MySQL table statement? Is this possible? I have tried separating the constraints using commas. Thank you.

    $update_error = mysqli_query($con, "UPDATE users SET error_level='3'
                    WHERE errors <= '650', errors > '200'");
Martin
  • 20,858
  • 7
  • 60
  • 113
apaul
  • 196
  • 2
  • 13

3 Answers3

2

You should add logical operator (https://dev.mysql.com/doc/refman/5.7/en/logical-operators.html) which will describe to MYSQL what is the connection between conditions:

It will look like this

mysqli_query($con, "UPDATE users SET error_level='3' WHERE errors <= '650' AND errors > '200'");

or this

mysqli_query($con, "UPDATE users SET error_level='3' WHERE errors <= '650' OR errors > '200'");
Funk Forty Niner
  • 74,372
  • 15
  • 66
  • 132
1

SQL :

WHERE errors <= '650'AND errors > '200'

You could also use BETWEEN ( I find this easier to read later )

WHERE errors BETWEEN 200 AND 650
0
UPDATE users SET error_level='3' WHERE errors <= '650' AND errors > '200'
BartBiczBoży
  • 2,232
  • 2
  • 22
  • 33