On 19.05., [EMAIL PROTECTED] wrote:
> If you add another command,
> mysql> insert into bla1 values (NULL, "Cello3", NULL) on duplicate key update
> whentime = NOW();
> The right ID will be used.

Yes, if I insert an new value then the ID column gets incremented. But if I
try to insert an existing value (in the second column), the LAST_INSERT_ID()
contains a random value (the next auto_increment value going to be used?)
afterwards.
So I can't rely in retrieving LAST_INSERT_ID().

> Since last_insert_id() has a connection scope, it's better for you to use :
> select max(id) from bla1;

That's not what I want. I need the ID of the row just inserted (for
referencing it from another table). 

If I select the max(id), then one the hand someone might have added another
row in the meantime and on the other hand is still don't get the ID value in
the ON DUPLICATE KEY UPDATE case ...

Sven

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to