Archive for the MySQL Category

MySQL makes stuff easy 2

Jul 6th, 2009 Posted in MySQL | no comment »

How to convert old html-symbols to utf-8 automatically in MySQL?

i did it with REPLACE():

UPDATE `articles` SET `title` = replace(`title`,'ä','ä');
UPDATE `articles` SET `title` = replace(`title`,'ö','ö');
UPDATE `articles` SET `title` = replace(`title`,'ü','ü');

… worked with all my old tables :)

MySQL makes stuff easy

Jul 1st, 2009 Posted in MySQL | no comment »

Recently, had to

MIGRATE `some`, `product`, `tables` FROM `different sources` WHERE `someone apparently typed letters in fields that were supposed to hold numbers only`;

Only problem: the table holds nearly 3000 rows.

So I used a regular expression:

SELECT * FROM `products` WHERE `price` REGEXP '[:alnum:]';

It took 0.0434 sec for MySQL to identify the badboys ;)