Solved

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

Posted on 2011-09-27
4
336 Views
Last Modified: 2012-05-12
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!
0
Comment
Question by:brendan-amex
  • 3
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
UPDATE SomeTable
SET SomeColumn = LEFT(SomeColumn, LEN(SomeColumn) - 3)
WHERE RIGHT(SomeColumn, 3) = "***"
0
 

Author Comment

by:brendan-amex
Comment Utility
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?
0
 

Accepted Solution

by:
brendan-amex earned 0 total points
Comment Utility
nevermind, figured it out.

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

0
 

Author Closing Comment

by:brendan-amex
Comment Utility
Found the answer myself online.

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now