Jump to content

SQLite LAST_INSERT_ROWID() problem


Recommended Posts

Posted
    local ID = dbExec(db, "SELECT LAST_INSERT_ROWID() FROM joinHistory") 

this returns false for me, even though the database isn't empty.

i'm trying to create an auto_increment column, but just found out that sqlite doesn't support auto_increment, it's only supported by MySQL.

any help?

Posted

Also, you can't use dbExec to get the ID. You'll have to use dbQuery + dbPoll as follows:

local result = dbPoll(dbQuery(db, "SELECT LAST_INSERT_ROWID() AS `ID`"), -1) 
outputChatBox(result.ID) 

("FROM joinHistory" isn't necessary according to the SQLite documentation btw)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...