Link to home
Start Free TrialLog in
Avatar of brendan-amex
brendan-amex

asked on

Remote last 3 asterisks (***) from MySQL Field

I'm trying to figure out how to write a query that will remove the last 3 asterisks from a VARCHAR field only if they exist. I can't find much on google, any help is appreciated! Thank you!
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

UPDATE SomeTable
SET SomeColumn = LEFT(SomeColumn, LEN(SomeColumn) - 3)
WHERE RIGHT(SomeColumn, 3) = "***"
Avatar of brendan-amex
brendan-amex

ASKER

I'm running this in MySQL (phpmyadmin to test before moving it into php) and it says "FUNCTION databasename.LEN does not exist" Is there another way to do this that will work on MySQL?
ASKER CERTIFIED SOLUTION
Avatar of brendan-amex
brendan-amex

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found the answer myself online.

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);