mysql 每条数据增加随机数
作者:互联网
UPDATE smokevehicle ta
-- 利用LEFT JOIN的方式进行关联修改
LEFT JOIN(
-- 先通过查询的方式给每一条数据生成对应的10-500之间随机数
SELECT
smokevehicleid ,
CAST(rand() * 1 + rand() * 10 AS SIGNED) vc
FROM
smokevehicle
) ta2 ON ta.smokevehicleid = ta2.smokevehicleid
SET ta.CaptureDateTime = date_add(ta.CaptureDateTime, interval (ta2.vc ) minute)
where ta.smokevehicleid in (1,2);
标签:rand,vc,ta2,smokevehicleid,每条,smokevehicle,随机数,mysql,ta 来源: https://www.cnblogs.com/luoguixin/p/15660781.html