I have a table with three columns. Column1 is id. Column2 is filename. Column3 is location. I need to write a query that will take all files with filename = X and will replace part of the string for 'location' lets say location = '/home/AAA/bin' and it will replace it with '/home/BBB/bin'. The start of location is always the same but the end is not always the same. I mean it will always start with /home/AAA/ but the end of the location is different for every file - /bin/ could be /somethingelse/.
1 Answer
You need to use this Postgres function
overlay(string placing string from int [for int])
ex: overlay('Txxxxas' placing 'hom' from 2 for 4)
Your situation involves the select statement having the following:
overlay(location placing '/home/BBB' from 1 for 9)
You can get more information from here.