Donovant Donovant - 15 days ago 5
MySQL Question

MySQL: how can I replace only first char if it contains a determinate char?

as title, I would to know how replace only the first char of a record if it contains a determinate char?


For example:

record: " hello" --> record "hello".


Here i remove the space from the string " hello"

Thanks

Answer

If YourField has a space as first character, use this. You can, ofcourse, change the first character to whatever you like.

UPDATE YourTable SET
YourField = RIGHT(YourField,LENGTH(YourField)-1)
WHERE YourField like ' %'