MySQL Forums
Forum List  »  Newbie

Re: why is this not working?
Posted by: Phillip Ward
Date: January 29, 2013 06:35AM

Quote

first I SELECT MAX(nr) and second call UPDATE
But I wanted to know how it works in one call.
And how many records are you going to have in this table, all of which you'll have to scan through in order to find the highest one before adding one to that value to create your new record (and hoping that nobody else does the same thing at [more or less] the same time, thereby generating a duplicate)?

If you really can't use auto_increment, then consider a separate, single-row table containing the last value used. Update that, incrementing it by one, then select the new value to insert into your table proper (which will work reliably in a multi-user application).

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
January 28, 2013 03:36PM
January 29, 2013 12:55AM
Re: why is this not working?
January 29, 2013 06:35AM
January 29, 2013 07:40PM
January 29, 2013 07:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.