Reputation: 5591
So, I realized that for my db column values, I have a whitespace in front of all strings.
(Couldn't figure out why WHERE name = "Sean"
wasn't working and by accident, I noticed that there was a whitespace at the front of the value: WHERE name = " Sean"
).
There are some values which a space in between words are needed.
UPDATE (realized that my question was not clear enough).
I am trying to update the db so that the whitespace at the beginning of each string is removed.
Thank you.
Upvotes: 0
Views: 1802
Reputation: 2148
Try: WHERE ltrim(name) = "Sean"
Link to documentation: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_ltrim
EDIT: Re-read and saw your edit, and noticed you wanted to update. In which case you'd want to run this for each column which has leading whitespace. Here is an example using a dummy table name, and your name column:
UPDATE table
SET name = ltrim(name)
That will update every row and remove any leading whitespace.
Upvotes: 2
Reputation: 1161
Use LTRIM
SELECT LTRIM(name)
Or do an update where you
SET name=LTRIM(name)
Upvotes: 1