update 表1 set a=100
追问:
如果这个值 我不希望它等于100,而是希望它的是值是小于100的随机整数,有办法实现吗
追答:
update 表1 set a=floor(rand()*100)
这个代表0-99的整数,不包括负数
追问:
太神奇了,真的实现了,我最后再请教高手 一个问题,如果我希望,这值是5,10,15,20,这四个数中随机的一个数,有办法实现吗,拜托给予解答
追答:
select t.num from
(select 5 num
union all
select 10 num
union all
select 15 num
union all
select 20 num) t
order by rand() limit 1
随机2个的话,就把limit后的数字换成2,以此类推
追问:
select t.num from(select 5 numunion allselect 10 numunion allselect 15 numunion allselect 20 num) torder by rand() limit 1 和 update 表1 set a=floor(rand()*100) 怎么组合呀,我试了老是错误 ,就是让a=这四个数中的一个
追答:
update 表1 set a=
(select t.num from(select 5 num union all select 10 num union all select 15 num union all select 20 num) t order by rand() limit 1)