MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Danny Haworth Date:September 18 2002 11:18am
Subject:Re: How to use Auto Increment
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| I am writing a script where I will have 2 insert statements
| The first insert is into a table which has an Auto_Increment field.
| I want to know the value which was inserted in this Auto_increment
field and
| use it in the second INSERT statement.
|
| How can I do it in MySQL.

after inserting into the auto_increment table, do a 'SELECT
LAST_INSERT_ID()' which will return the last autoincremented value. You
can use this value in your second insert statement.

danny

- --

Danny Haworth
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ge2 System Administrator
Gas~Elec Safety Systems
Tel : 01895 422 997
Email : dan@stripped (mailto:dan@stripped)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE9iGENUKf+497XC3QRAinfAJ0dgODNkRypaa/5D9R4VA8LAwoalQCfTwnm
YOkwrvwm7ZWfvH8rwVhcDFc=
=k+A3
-----END PGP SIGNATURE-----

Thread
How to use Auto IncrementRajesh Kanade18 Sep
  • Re: How to use Auto IncrementDanny Haworth18 Sep
  • Re: How to use Auto IncrementNeil Mansilla18 Sep
Re: How to use Auto IncrementPaul DuBois19 Sep