Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@@identity? 1

Status
Not open for further replies.

hads

Technical User
Nov 12, 2001
257
AU
Hi all,

I'm brand new to MySQL (used to MSSql using ASP) I'm trying to move in the open source direction so I'm converting one of my ASP/MSSql apps to PHP and MySQL.

Anyway, in this app I use a SELECT @@Identity on the end of a query to get the autonumber of a record that was just inserted. Can someone give me a shove in the right direction as to how I go about doing this with MySQL?

Cheers.
[smurf]
01101000011000010110010001110011
 
If you want to use the PHP way of doing it, mysql_insert_id() is the way to go. Like this
mysql_query("INSERT INTO table VALUES (NULL, 'blah')");
$id = mysql_insert_id();
MySQL's function of doing it is LAST_INSERT_ID(). //Daniel
 
Cool,

Cheers for that, that gives me something to work with.

[smurf]
01101000011000010110010001110011
 
Status
Not open for further replies.

Similar threads

Replies
5
Views
46

Part and Inventory Search

Sponsor

Back
Top