'How to update data in Mysql using "not equal" condition
I have a database that has a table named property_list, and a column named agent. for now there is a lot of name inside it.
$agent = array("Tony","Nava","Ceri","Van","Turker");
Many things happen lately, and most of them are out and we need to change their name to Property Agent in table "property_list", except agent named Ceri and Van.
i have try this Query but it apperantly changes all the agent list at the table
UPDATE property_list SET agent = "Property Agent" WHERE agent != "Ceri" OR agent != "Van";
am i do it wrong?, currently using mysql and php to run the code.
Solution 1:[1]
Use AND instead of OR if you want to update all records except Ceri and Van
UPDATE property_list SET agent = "Property Agent" WHERE agent != "Ceri" AND agent != "Van";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ainz |
