Solved

Remove all characters to the left of a specified character

Posted on 2011-03-08
2
345 Views
Last Modified: 2012-05-11
I have a column of data that has text like "New Price, now only $5.99"  

I would like to remove all the characters to the left of the dollar sign.

It would leave only the $5.99
0
Comment
Question by:theideabulb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35075992
Something like this should do it:

SUBSTRING ( mystring , CHARINDEX ( mystring, '$' ), 10 )

Open in new window

see:

CHARINDEX ( expression1 ,expression2 [ , start_location ] )

http://msdn.microsoft.com/en-us/library/ms186323.aspx

SUBSTRING ( expression ,start , length )

http://msdn.microsoft.com/en-us/library/ms187748(v=sql.90).aspx
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35082889
sjklein: the question is for MySQL, not mssql server.

the logic is the same, though, using the INSTR or LOCATE functions
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_instr
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate

and the substr / mid function(s):
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_mid
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring

watch out though about the order of the arguments in INSTR vs LOCATE (vs CHARINDEX), it's not always the same !
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

615 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