Andrew (deltoideus) wrote in mysql,
Andrew
deltoideus
mysql

inserted row ID

Hi guys, i'm a newbie to MYSQL, so excuse me for stupid questions :)
I have the following question:
For instance my database looks like -
+====+============+
| ID | SOME_VALUE |
+====+============+
| 10 |  MY_VALUE  |
+----+------------+
|    |            |
+----+------------+
ID - is auto_increment
I use php and make MYSQL query to insert a new row (INSERT query)
Is there any way to know inserted row ID?

-----------------------
PS. If i use

(1) INSERT INTO ... ... ... VALUES ... ... ...;
(2) SELECT LAST_INSERT_ID();

can i be 100% sure that another INSERT query (from another user) won't be inserted between (1) and (2) and the returned ID will be wrong?
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 8 comments