In my testing, the below query stores only "abc" and not "abc ".
UPDATE tablename SET fieldname = 'abc ' WHERE someid = 1
Why MySQL is not storing "abc " in database and stores only "abc". It is storing " abc" well in db.
Never investigated this before, but: http://www.informit.com/articles/article.asp?p=30885&seqNum=7
With the point being
There is also a third, minor difference between these two: MySQL trims off extra spaces from CHAR columns when data is retrieved and from VARCHAR when it's inserted.
A solution would be to replace trailing spaces with , or %20 Or you could simply accept this misfeature (or misbug, depending on how you look at it).
EDIT: here's the official source: http://dev.mysql.com/doc/mysql/en/CHAR.html
For CHAR:
When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed.
For VARCHAR:
Values are not padded; instead, trailing spaces are removed when values are stored. (This space removal differs from the standard SQL specification.)