how could i remove ALL whitespaces from a row? I see here alot of same question but all answers ar to use replace option. Replace will work only to strip one spaces, not all.
ex: a b c to become a-b-c
Thanks.
Remove all the whitespaces from the entire column values We will be using the replace() function as replace() function will remove the white spaces from between, start, and the end of the string value. Name of the table. Name of the column whose values are to be updated.
The TRIM() function returns a string that has unwanted characters removed. Note that to remove the leading spaces from a string, you use the LTRIM() function. And to remove trailing spaces from a string, you use the RTRIM() function.
The function REPLACE(str, " ", " ") only removes double spaces, but leaves multiples spaces when there are more... Check this answer stackoverflow.com/questions/986826/… . The OP wants to do the same but with other characters.
This can be achieved with the following MySQL Function:
SELECT REPLACE( table.field, ' ', '-' ) FROM table;
This should replace all the whitespace to a -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With