2011/03/08

Llenar aleatoriamente una tabla con una matriz

Mediante elt y rand se toman los valores aleatoriamente de una matriz:

ELT(0.5 + RAND() * 6, 'a', 'b', 'c', 'd', 'e', 'f')

Un ejemplo:

mysql> update catDirectory set item=(ELT(0.5 + RAND() * 6, 'MARISCOS Y PESQUERAS', 'ROSQUILLAS', 'CEREALES', 'BEBIDAS', 'ESPECIES', 'PANELA')) where (ISNULL(item));

Query OK, 283 rows affected (0.01 sec)
Rows matched: 283 Changed: 283 Warnings: 0