List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:June 4 1999 12:26am
Subject:insert .. select and mysql_insert_id
View as plain text  
>>>>> "Sheamus" == Sheamus Nulty <snulty@stripped> writes:

Sheamus> Folks,
Sheamus> I'm  running a query where I'm moving data from a temp table. To do this I'm
Sheamus> using insert in conjunction with select. i.e. insert into Orders (......)
Sheamus> select .. from temp where session_id='XYZ'

Sheamus> Now the insert works perfectly but the problem I'm having is that if I run
Sheamus> mysql_insert_id after this query it keeps coming back as 0. However, if I
Sheamus> change the query to something like insert into Orders (...) values (...)
Sheamus> then I get back the correct value for the auto incrementing field.

Sheamus> So is it the case that I can't use the top query to move the data. I'm
Sheamus> running mysql version 3.21.31 on solaris 2.51 .

Sheamus> Thanks

Sheamus> Sheamus

Hi!

The above problem is fixed in MySQL 3.22, so the 'easy' solution is to 
upgrade :)

Regards,
Monty
Thread
insert .. select and mysql_insert_idSheamus Nulty3 Jun
  • insert .. select and mysql_insert_idMichael Widenius4 Jun