All data in column foo are suffixed by a _. I want to delete this _. Can I do it using SQL rather than writing a script?
All data in column foo are suffixed by a _ . I want to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A few ways to do it:
TRIMthe trailing ‘_’:Grab the substring consisting of characters 1 to n-1, n being the length of the string in
foo, usingSUBSTRINGandCHAR_LENGTH:I’d recommend the first method as, if you have, say, one row in
foothat doesn’t end in ‘_’, the first method will leave it as is, whereas the second will take of its last character even though that isn’t an underscore.