x

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 3 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 5 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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x65

asked: Nov 06 '09 at 08:00 PM

Seen: 1716 times

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