更新两个表的字段是怎么可能的,而且是否有可能?
UPDATE workers INNER JOIN reviews_of_workers
ON workers.id = reviews_of_workers.worker_id
SET
@competence_rand = 7+FLOOR(RAND()*4),
@speed_work_rand = 7+FLOOR(RAND()*4),
`reviews_total` = 1,
`competence_total` = @competence_rand,
`speed_work_total` = @speed_work_rand,
`competence` = @competence_rand,
`speed_work` = @speed_work_rand
WHERE `workers`.`id`>=64508716;
问题是该块不起作用:
@competence_rand = 7+FLOOR(RAND()*4),
@speed_work_rand = 7+FLOOR(RAND()*4),
如果你把它放在前面UPDATE
,那么它就可以工作,但它是为所有行计算一次的。
我怎样才能使它每次为每一行计算值UPDATE
?能以某种方式通过存储过程吗?