Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

Is it possible using SQL in an SQLite table to replace part of a string?

For example, I have a table where one of the fields holds the path to a file. Is it possible to replace parts of the string so that, e.g.

c:\afolder\afilename.bmp

becomes

c:\anewfolder\afilename.bmp

?

1 Answer

0 votes
by (40.7k points)

You can try using the built-in replace() function to perform a string replace in a query.

SQLite core functions list Refer to this to learn string manipulation functions.

You can use the following code: 

UPDATE table SET field = replace( field, 'C:\afolder\', 'C:\anewfolder\' ) WHERE field LIKE 'C:\afolder\%';

Related questions

0 votes
1 answer
asked Jul 27, 2019 in SQL by Soni Kumari (40.7k points)
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...