Donovant Donovant - 9 months ago 60
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"


Answer Source

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

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