If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Where's wrong with my statement?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-04, 15:00
sunnyside sunnyside is offline
Registered User
 
Join Date: Aug 2003
Posts: 30
How to get the latest inserted ID

I'm developing a php web application. When I insert a user's information from a html form to a USER table, I also need to insert some data to 2nd table. There's a "contact_id" in 2nd table related with "user_id" (auto_increment) in USER table. But I just don't know how I can get the latest inserted user's ID from USER table and insert it into the 2nd table "contact_id" field.

Please give me some hint.

Last edited by sunnyside; 09-27-04 at 15:55. Reason: previous problem has been solved
Reply With Quote
  #2 (permalink)  
Old 09-27-04, 16:22
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
use the mysql_insert_id() function
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-27-04, 17:37
sunnyside sunnyside is offline
Registered User
 
Join Date: Aug 2003
Posts: 30
Thank you so much. Help me a lot! :-)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On