Donovant Donovant - 1 year ago 75
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 ' %'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download