is there a way to 'insert and fetch value'?

This is a discussion on is there a way to 'insert and fetch value'? within the MySQL Database forums, part of the Database Forums category; I am writing a DB like this: --------------------------------------------------------------------- | id (auto_incremented filed) | foo | bar | --------------------------------------------------------------------- $sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-20-2007
newbie
 
Posts: n/a
Default is there a way to 'insert and fetch value'?

I am writing a DB like this:
---------------------------------------------------------------------
| id (auto_incremented filed) | foo | bar |
---------------------------------------------------------------------

$sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);
//how can I get id for the above inserted entry? is that possible I
get it with a single mysql instruction?


since each time I write a record into mysql, 'id' is incremented,
how can I get the id that an insertion corresponds to (can I get it
with a single mysql instruction)?

Thanks,

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0