-ffs-AbodyRulez Posted August 27, 2015 Share Posted August 27, 2015 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? Link to comment
JR10 Posted August 27, 2015 Share Posted August 27, 2015 SQLite supports auto-increment. A column declared "INTEGER PRIMARY KEY" will auto-increment. You can use last_insert_rowid() without specifying a table. SELECT LAST_INSERT_ROWID() Link to comment
Jusonex Posted August 27, 2015 Share Posted August 27, 2015 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) Link to comment
JR10 Posted August 27, 2015 Share Posted August 27, 2015 I didn't even notice that he was using dbExec. dbExec never returns results, it only executes the given query. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now