[SOLVED] How to update data in Mysql using "not equal" condition

Issue

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

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";

Answered By – Ainz

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.