开发者

How to handle simultaneous data request and response in mysql database?

开发者 https://www.devze.com 2023-04-12 17:38 出处:网络
The problem scenario is: I have a database table \'User_Datails_Table\' with fileds(id,username, luckyNumber).

The problem scenario is:

I have a database table 'User_Datails_Table' with fileds(id,username, luckyNumber). All logged in users can updated their 'luckyNumber' as they wish. Also a user has option to view all the existing user details. There is an option to sort(DESC) the user details based on 'luckyNumbers'.

The requirement is such that I need to query the database with LIMIT values. For example,query fetching 1st two records(LIMIT 0,2), then next query fetching next 2 records(LIMIT 2,2) so on.

Conside开发者_开发百科r the database contains 4 record:

id  username   luckyNumber
1   USER1       67
2   USER2       66
3   USER3       64
4   USER4       63

Two user(USER1 and USER3) are logged in.

If USER3 fetches the first two records using LIMIT 0,2( result is USER1 and USER2) and USER1 changes his luckyNumber to 62(simultaneously).

Now if USER3 fetches the next two records using LIMIT 2,2( result is USER4 and USER1). So USER1 gets repeated in the result.

I use php to fetch the mysql database. How can such a scenario be handled? Does mysql handle this automatically?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号