Databases 3 min read

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.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Why MySQL UPDATE Appears to Do Nothing and How to Fix It

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databasemysqltroubleshootingSQL syntaxUPDATE
Java Backend Technology
Written by

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!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.