首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

该条语句运行好久,什么有关问题,该怎么优化

2012-05-20 
该条语句运行好久,什么问题,该如何优化update user_score set score(score+5)where acc_nbr in (select c

该条语句运行好久,什么问题,该如何优化
update user_score set score=(score+5)
where acc_nbr in (select calling_nbr from tb_up50_call where calling_nbr!=called_nbr
 group by calling_nbr);

是score=(score+5)计算,和acc_nbr in还有group by 的问题么?
谢谢解答!

[解决办法]
update user_score ,(select calling_nbr from tb_up50_call where calling_nbr!=called_nbr) b
set score=(score+5)
where acc_nbr=calling_nbr
[解决办法]
--如果索引都加了,用exists效率应该会高些
update user_score set score=(score+5)
where acc_nbr exists (select calling_nbr from tb_up50_call where calling_nbr!=called_nbr
 group by calling_nbr);

热点排行