Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract data from a string 1

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
There is a field with:

/detail.php?subject=test&catalog=558

The field could also have

/detail.php?subject=test&catalog=558&section=1

The field could also have

/detail.php?subject=test&catalog=558&section=1&term=1068

Is there a way in a select statement to extract the data so I have

test
558
1 have this data if section is in the string
1068 have this data if the term is in the string

Help is appreciated.
 
You probably could do it in MySQL, but I think it'd be easier in another language. Does it have to be done in a SQL statement?

-----------------------------------------
I cannot be bought. Find leasing information at
 
I have reporting tool that I'll connect to the mysql database so I think I'll do it in that tool. Thank you. I probably should have this in a different thread but I thought maybe you could help me using this thread (I can start a different thread if needed):

I have another string field:

01/Mar/2010:07:41:59 -0700

I was able to extract the date using SUBSTRING_INDEX( c.entry, ':',+1 ) so I have 01/Mar/2010

Question?

Is there a way to extract the date and format it as 03/01/2010 instead of 03/Mar/2010 in 1 expression?

Thank you
 
You should be able to do something like
Code:
date_format(str_to_date(SUBSTRING_INDEX( c.entry, ':',+1 ), "%d/%b/%Y"), "%c/%d/%Y")

-----------------------------------------
I cannot be bought. Find leasing information at
 
jaxtell,

Sorry, it took me so long to reply. It's been crazy. Your formula worked wonderful. Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top