Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQL Statement needed

  • 03-10-2004 02:28AM
    #1
    Registered Users, Registered Users 2 Posts: 885 ✭✭✭


    Hi

    I need a sql statement that will insert a new record into a mysql database and return the Primary key for that record which is an auto incrementing number.

    Thanks


Comments

  • Closed Accounts Posts: 79 ✭✭zt


    Something like this will work with MySQL ..

    INSERT INTO myTable (fieldA,fieldB,fieldC) VALUES (3,4,5)

    SELECT LAST_INSERT_ID()

    The last_insert_id will return the last id generated on the current connection.


Advertisement