Monday, 24 September 2007

MySQL search and replace goodness

Why I love MySQL.....



mysql> UPDATE selldata SET advert = REPLACE(advert,'_','-');
Query OK, 2 rows affected (0.15 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> SELECT advert FROM selldata;
+------------------+
| advert |
+------------------+
| 1188978590-1.htm |
| 1188978590-2.htm |
+------------------+
2 rows in set (0.00 sec)

mysql> UPDATE selldata SET advert = REPLACE(advert,'-','_');
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> SELECT advert FROM selldata;
+------------------+
| advert |
+------------------+
| 1188978590_1.htm |
| 1188978590_2.htm |
+------------------+
2 rows in set (0.00 sec)

No comments: