Home > Archive > PHP Language > August 2005 > mysql autoincrement- return id
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mysql autoincrement- return id
|
|
|
| Hello,
I have a table with column ID of auto increment type.
I want to insert a record in the table and then I want to show it's ID.
My best idea is to count the records in the table after inserting the
record.
But if 2 people will insert different records in the same time in the same
table, then
it is possible that they will get wrong ids.
To be sure that the script will always return right id I can write a sql
query that will search the table for record of values same as the ones, that
have been just saved.
But- can I do it easier and faster?
Regards,
Talthen
| |
|
|
|
| User nicknamed <jdonkers@gmail.com> :
> use mysql_insert_id() direct after your INSER Query.
Thanks, that's *exactly* what I wanted :]
Regards,
Talthen
|
|
|
|
|