MySQL thread related issues, ask the heroes, top people have points

Source: Internet
Author: User
MySQL threading problem, ask the heroes, the top has points!
Select number from numbertable where number=
(
SELECT sum (todayhit) as Todayhit from Hittabel
)

I want to do a click Statistics, when the total number of users click SUM (todayhit) is equal to the numbertable table in the numbers (in advance set), will give the Netizen a prize,

The problem with this statement is that when there are a lot of people at the same time, will be empty number, so that I set the winning numbers missing, this problem only when the number of simultaneous clicks, I personally think is the MySQL thread problem, the hero has a good idea, let my operation does not miss the winning numbers, can not use the database, As long as it can be achieved.

------Solution--------------------
Do you understand
------Solution--------------------
Will there be an empty number problem?
------Solution--------------------
jf~~
Next manual look, quite detailed.
In general (for reference, the specific manual +google bar)
To the library where the table is located
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;
Unavailable:
Mysql> call Test (@num);
Mysql> Select @num;
------Solution--------------------
There is a way to solve, is to lock the table.

It seems that there are too few people reading the handbook. MySQL library, there are many kinds, which self-supporting lock table and lock the library, then just a few, please look at the manual a little bit.

I use this aspect of things relatively few, specific content, forget. Sorry AH ~
------Solution--------------------
MySQL stored procedures are not recommended
Not mature ...
------Solution--------------------
Rollback
------Solution--------------------
Top

------Solution--------------------
Transaction
------Solution--------------------
I basically don't use the stored procedure
------Solution--------------------
Take a different perspective on the problem ...
Or a system architecture design issue.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.