Reputation: 51
I have to fill a column called "provicias" from a table "padron_filtrado" but this column "provincias" just can have this six variables: "Heredia","San Jose","Cartago","Puntarenas","Alajuela","Limon","Guanacaste". and i must have to fill it random.
I know how to make a rand of dates or numbers but not with varchars..
Upvotes: 0
Views: 67
Reputation: 1270401
You can use the elt()
function and rand()
to do this:
update padron_filtrado pf
set pf.provicias = elt(1 + floor(rand()*7),
'Heredia', 'San Jose', 'Cartago', 'Puntarenas', 'Alajeula, 'Limon', 'Guanacaste'
);
I counted seven values in your list rather than six.
Upvotes: 1