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.