Updating parts of SQL Data
I am trying to update part of SQL data but am not getting it to work. Here is my example. I have a row that has the data "apple.mid" in a column called url. I want to change the extension of the data to "apple.zip". Is there a way to only change part of the data?
I tried this:
SET url = url+'.zip'
WHERE url like '%.mid' AND id = '2'
But I am not getting the right value.
If you are using MySQL, this might do the trick:
UPDATE dir_pages SET url = REPLACE(url, '.mid', '.zip')
WHERE url like '%.mid' AND id = '2';
and that worked! thank you, didnt even know there was a replace function in mysql
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)