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
  • 22,212
  • 11
  • 70
  • 132
apaul
  • 308
  • 3
  • 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,450
  • 15
  • 68
  • 141
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,512
  • 2
  • 24
  • 33