If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > quick seemingly difficult question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-04, 14:05
gimboid4124 gimboid4124 is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
Angry quick seemingly difficult question

hi,

i use MySQL, and have a table where each user is allocated a number (x) which is different for each user. To find a value of X for a new user (g), the function (MAX(users.x)+1) is used to find the new x for a new user, and an insert statement, "insert (username (g), x) into users" (near enough ;P) is used to add a user and his value of x to the table. These queries are both done by a php script one after another. how can i be sure that they are done one after the other by the database, by that i mean, how do i know that someone hasnt inserted a new record in between the max(users.x)+1 has been found, and inserting the user (g) for which max(users.x)+1 has been found, thus making this value wrong (as someone will have already selected that value) (since finding max(users.x)+1 again will weild a different answer). Using an auto_increment is not an option.

cheers
gimboid
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On