MYSQL

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Last Inserted ID Using LOAD DATA

    1 answers - 322 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have a group of updates that need to be done using LAD DATA INFILE.
    Within this file there are some INSERTS. Is there anyway that after
    an INSERT happens I can use the auto-increment ID that was just
    generated in the next statement. Similar to PHP's mysql_insert_id()
    function.
    Thanks,
    Michael
  • No.1 | | 996 bytes | |

    Hi,

    Your query was understood as - you want to retrieve the current value of
    the autoincrement column, where mysql_insert_id also reveals the same.

    Try either of this.

    Use LIMIT:

    select ID from tablename
    order by ID DESC
    LIMIT 1.
    or
    Use MAX()

    select MAX(ID) from tablename

    Thanks
    ViSolve DB Team.

    Message
    From: "Michael Stearne" <mstearne (AT) entermix (DOT) com>
    To: <mysql (AT) lists (DOT) mysql.com>
    Cc: "Jim Ginn" <jim (AT) oats (DOT) com>
    Sent: Tuesday, September 19, 2006 10:11 PM
    Subject: Last Inserted ID Using LAD DATA


    >I have a group of updates that need to be done using LAD DATA INFILE.

    Within this file there are some INSERTS. Is there anyway that after
    an INSERT happens I can use the auto-increment ID that was just
    generated in the next statement. Similar to PHP's mysql_insert_id()
    function.

    Thanks,
    Michael

Re: Last Inserted ID Using LOAD DATA


max 4000 letters.
Your nickname that display:
In order to stop the spam: 7 + 6 =
QUESTION ON "MYSQL"

EMSDN.COM