Why MySQL UPDATE Appears to Do Nothing and How to Fix It
This article explains why a syntactically correct MySQL UPDATE statement may seem ineffective, demonstrates the difference between using commas and the AND operator for multi‑column updates, and provides the proper syntax to ensure the intended rows are modified.
Several developers have reported that an UPDATE statement in MySQL executes without errors but appears to leave the record unchanged.
The problematic SQL (shown in the original image) uses the AND keyword to separate column assignments.
Before execution the record looks like the first screenshot, and after execution the second screenshot shows that the data actually changed, contrary to the developer’s expectation.
Reviewing the MySQL documentation reveals that the SET clause of an UPDATE must list column_name = value pairs separated by commas, not by AND. The correct multi‑column update syntax is illustrated in the following image.
Re‑running the statement with commas instead of AND produces the expected result, as confirmed by the third screenshot.
Key Takeaway
When updating multiple columns in a single UPDATE statement, separate the assignments with commas rather than the AND keyword.
Postscript
Using AND creates a logical expression; for example, ('43212' AND owner_name='李四') evaluates to FALSE, which MySQL treats as 0. This explains why unexpected values such as owner_code=0 can appear.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
