Using REPLACE in an UPDATE statement to fix data on MSSQL and MySQL

Sometimes it’s necessary fix data on the database. I had to fix on a Microsoft database: I had to fix…

Gennaio 21, 2010

Sometimes it’s necessary fix data on the database.
I had to fix on a Microsoft database:

      /* MSSQL syntax */
      update table_links set url  = Replace(url, 'www.link.it/web3', 'www.link.it/web') where url <>''

I had to fix on a MySQL database:

      /* MySQL syntax is the same! */
      UPDATE table_links SET url =REPLACE(url, '&amp;', '&') where url<>''

The syntax is the same.

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.