MySQL replace all whitespaces with -
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 开发者_如何学Cwork only to strip one spaces, not all.
ex: a b c to become a-b-c
Thanks.
This can be achieved with the following MySQL Function:
SELECT REPLACE( table.field, ' ', '-' ) FROM table;
This should replace all the whitespace to a -
update image set path = REPLACE( image.path, ' ', '-' ) where path like '% %'
if you would like to update the path in mysql itself use the update for all rows which have spaces withe %20
Try this
replace('a b c',' ','-')
UPDATE table SET table.field = REPLACE( table.field, ' ', '-' );
This will update all the fields, replacing all spaces with hyphens. This will actually modify the data in the tables. Fokko's answer above will change only the data that is pulled, therefore not changing the actual data.
精彩评论