Jack_90 Jack_90 - 1 year ago 79
MySQL Question

Updating varchar has no effect

I want to update a varchar column with the update clause like this:

UPDATE ptl SET version=NULL WHERE version = 'a';

and MySQL gives me this answer:

Query OK, 0 rows affected

I have several entries where the version is 'a' like for example this one:

Title version
Hiper a

And after my update statement it should turn into following:

Title version
Hiper NULL

but it does stay the same.

Why does it not change?

Answer Source

What looks like an "a" would not seem to be solely an 'a'. This can be for a variety of reasons. Start with:

select length(ptl.version), ptl.version 
from ptl
where version like '%a%'
order by length(ptl.version);

You can see the length of the version being returned.

You might have other characters such as spaces in the value. Or, you might have a utf character that happens to look like a lower-case a. In the latter case, the above may not return anything.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download