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!

mySQL find and replace extension?

Status
Not open for further replies.

johno69

Technical User
Nov 20, 2001
1
GB
I have a table called 'urltech' in a mySQL database. I store urls's like this: 'data/name_data.htm' - I just need to change all the extensions from '.htm. to '.pdf'.
Any ideas?
 
i have not used that yet but try
update urltech set columnname = REPLACE(columnname, 'htm', 'pdf')
 
As Piti says, this will work, I've done it myself, although I would use ".htm" & ".pdf" in the REPLACE statement otherwise, it may replace any occurrence of the letters "htm" in your data, not just the extensions.

Mark.
 
well you're right, i was not thinking about that, i just wrote down a sample code for replacing strings

btw - what about a link with filename "data.htm.htm" ;-)))
 
> btw - what about a link with filename "data.htm.htm"
LOL
I think that's then a job for good ol' Perl then :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top