Help - Search - Members - Calendar
Full Version: 2 queries, same id
Invision Power Services > Community Forums > Community Web Design and Coding
Kenny Pollock
I'm trying to run two queries. The second one enters data into a second table...but needs the id (auto incremented) from the first insert query. Is there any solution for this?

Sorry for bad typing... broke my hand last night, hard to get used to one finger typing.
James Mathias
So to be clear,

You are running a query that adds a new record to your table, using an auto_incremeted ID

Then a second query that requires the ID from the first queries record.

Are you running them at the same time, or in order?
RobertMidd
http://uk.php.net/mysql_insert_id
elj
Would mysql_insert_id work? http://www.php.net/manual/en/function.mysql-insert-id.php
Kenny Pollock
Thanks, I think that's exactly what I was looking for.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.