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'");
1

3 Answers 3

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'");
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

0
UPDATE users SET error_level='3' WHERE errors <= '650' AND errors > '200'

1 Comment

You might in words point out the difference between a comma and an AND...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.