Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Update Replace part of text from a string

I'm using MS Access and I have a table called Backup and a column named ImageURL. The ImageURL column has data such as: http://domain.com/s/1234.jpg.

I want to change the /s/ in the URL intoto /l/ by using an MS Access SQL Update and Replace.

When I'm trying it at the moment, it's replacing the entire field to /l/.

Thanks for your help!

Rob

like image 314
user1531184 Avatar asked Jul 17 '12 08:07

user1531184


People also ask

How do you UPDATE part of a string?

Update Part of a String in SQL Using the REPLACE() Function It replaces all occurrences of a specified string value with another string value. The REPLACE function returns a string where it replaces a substring with another substring.

How do I remove a specific part of a string in SQL?

We can remove part of the string using REPLACE() function. We can use this function if we know the exact character of the string to remove. REMOVE(): This function replaces all occurrences of a substring within a new substring.

Can we use Replace in UPDATE query?

You can use REPLACE in an UPDATE statement.

Can we use substring in UPDATE query?

Certainly! You can use the SUBSTR operator to get a substring from a field. For example, to get bytes 3-7 of a field called MYNAME, use the expression SUBSTR(MYNAME,3,5). You can update part of a character field by concatenating the parts you want to stay intact with the new value.


1 Answers

Update Backup
set ImageURL =replace(ImageURL,'/s/','/I/')
like image 64
Madhivanan Avatar answered Oct 12 '22 03:10

Madhivanan