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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I return only part of a string from a column?

Status
Not open for further replies.

JanetH

Technical User
Dec 31, 2003
6
0
0
US
I have created a stored procedure that will retrieve the number of hits on each page of a website by month. The column in the database that contains the page title contains almost the full web address for each page minus the root ex. /sample/archive/archive1.htm. My second problem is that each page title is a different length and may have as many as three "/'s". I want to display only the last word in the address ex. archive1.htm. Is there any way to do this using SQL and not a report type application. The stored procedure emails the results to me.
 
I suspect this depends on the database you are using. In Oracle you can easily get the instr function to search backwards from the end of a string by specifying a negative number as the third input parameter. Therefore, if your column name is called "page_title" the query would be

select substr(page_title,
instr(page_title, '/', -1) + 1,
length(page_title))
from your_table;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top