-1

There is a table which stores a file's location on my disk. All files are in one folder and I will move them to another folder. After moving the files I should update all database records.

Can I do it with one SQL query (applying a mapping function to all values in the fileLocation column) instead of selecting each value to update separately?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Stephen.W
  • 1,649
  • 13
  • 14

1 Answers1

0

If you moved everything from oldFolder to newFolder, you can use the REPLACE() function to update this in the table.

UPDATE yourTable
SET fileLocation = REPLACE(fileLocation, 'oldFolder', 'newFolder');
Barmar
  • 741,623
  • 53
  • 500
  • 612