x
login about faq Site discussion (meta-askssc)

MYSQL Trimming Data until it hits a special character

Is there a way to trim all the characters before it hits a special character. For example the table has data such as "\SERVER01\printer01". I do not want to display \SERVER01\ The output i want is printer01

Please help!

more ▼

asked Nov 06 '09 at 08:00 PM in Default

tyou gravatar image

tyou
11 1 1 1

Please note that thisforum is specifically for Microsoft SQL Server, so the folk here may not have good knowledge of MySQL

Nov 07 '09 at 09:51 AM Kristen ♦
(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
            
select col,right(col,locate('\',reverse(col))-1) from your_table            
more ▼

answered Nov 09 '09 at 04:52 AM

Madhivanan gravatar image

Madhivanan
1.1k 1 2 6

What did you change? Added code tag?

Nov 09 '09 at 10:34 AM Madhivanan

Yeah, I put

 
tags around your code as I thought the automatic colour coding (which you get if you use 4-space-indentation) looked a bit naff, hope you don't mind?. (In case you are not aware: if you click on the "Edited 22 hours ago" thingie by my name you'll normally see the change in the history list - it doesn't show the PRE tag though
Nov 10 '09 at 07:55 AM Kristen ♦

Thanks for the comment

Nov 10 '09 at 09:31 AM Madhivanan

Why does comment require minimum 15 characters?

Nov 10 '09 at 09:34 AM Madhivanan

Stop comments with just YES / NO perhaps?

Nov 10 '09 at 06:47 PM Kristen ♦
(comments are locked)
10|1200 characters needed characters left

SELECT PARSENAME(REPLACE(Col1, '\', '.'), 1) FROM Table1

more ▼

answered Nov 10 '09 at 07:33 AM

Peso gravatar image

Peso
1.6k 4 6 8

I don't think PARSENAME is available MySQL ?

Nov 10 '09 at 07:57 AM Kristen ♦

Yes not supported in mysql

Nov 10 '09 at 09:34 AM Madhivanan
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x52

asked: Nov 06 '09 at 08:00 PM

Seen: 1132 times

Last Updated: Nov 07 '09 at 09:51 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.