inserted row ID

    Date: 12/02/04 (MySQL Communtiy)    Keywords: php, mysql, database, sql

    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?

    Source: http://www.livejournal.com/community/mysql/43111.html

« My brain hurts... || MySQL support for AMD64 »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home