Home  >  Article  >  Backend Development  >  mysql 线程有关问题,请问大侠们,顶者有分

mysql 线程有关问题,请问大侠们,顶者有分

WBOY
WBOYOriginal
2016-06-13 13:50:39625browse

mysql 线程问题,请教大侠们,顶者有分!
select   number   from   numbertable   where   number=  
(
        SELECT   sum(todayhit)   as   todayhit   FROM   hittabel
)  

我要做个点击统计,当所有网民的点击总数sum(todayhit)等于numbertable表中的number(提前设定)时,会给这个网民奖品,

这个语句出现的问题是,当有很多人同时点是时,会空掉number,使我设定的中奖数字漏掉,这个毛病只有当同时点击人数很多时出现,我个人认为是MYSQL线程问题,大侠有没有好的主意,让我的操作不漏掉中奖数字,可以不用数据库,只要能实现.

------解决方案--------------------
么明白
------解决方案--------------------
会出现空掉number的问题嘛?
------解决方案--------------------
jf~~
下个手册看看,挺详细的。
大体如此(供参考,具体手册+google吧)
到表格所在库
mysql> delimiter //
mysql> create procedure test(out p int)
mysql> begin
mysql> SELECT @a:=sum(todayhit) FROM hittabel;
mysql> select select number into p from numbertable where number=@a
mysql> end;//
mysql> delimiter ;
用时:
mysql> call test(@num);
mysql> select @num;
------解决方案--------------------
有办法解决,就是对表进行锁定。

看来现在看手册的人太少了。MySQL的库,有很多种,其中自持锁定表和锁定库的,就那么就几个,请你稍微翻阅下手册吧。

我用这方面的东西比较少,具体的内容,忘记了。对不住啊~
------解决方案--------------------
不建议MYSQL存储过程
不成熟...
------解决方案--------------------
rollback
------解决方案--------------------


------解决方案--------------------
事务
------解决方案--------------------
我基本不用存储过程的
------解决方案--------------------
换个角度去思考这个问题...
或者是系统架构设计问题.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn