Reputation: 1108
I'm trying to cleanse my numbers in my database by using :
update valuations set Telephone = TRIM(Telephone) where 1 = 1
but 0 rows are effected and all the nunmbers still have a space in them. The datatype is varchar so im unsure why this isn't working - can anyone help?
Thanks
Upvotes: 6
Views: 3178
Reputation: 2776
trim()
will remove only those spaces at the ends of a string. If you want to remove those inside the string, use replace:
UPDATE valuations SET Telephone = REPLACE(Telephone, ' ', '') where 1 = 1
Upvotes: 3
Reputation: 1981
You should first trim string and after that replace space with empty character:
update valuations set Telephone = REPLACE(TRIM(Telephone), ' ', '') where 1 = 1
TRIM
function is useful when you need to remove other blank characters from begining and end of string, for example new line character or TAB.
More about TRIM()
function: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_trim
Upvotes: 2
Reputation: 474
Hi pandemic please use
UPDATE valuations SET Telephone = REPLACE(Telephone, ' ', '') WHERE 1 = 1;
Hope this works pal
Upvotes: 2