javascript - "SELECT MAX(rowid) FROM table" query works only after "SELECT * FROM table" has been called -


the below function in javascript file. intent return maximum value in rowid column of sqlite database. currently, works after "select * table query" has been run. why this?

function lastrecord(){   db.transaction(function (tx) {       tx.executesql('select max(rowid) mr surveys', [], function(tx, results){   var maxrowid = results.rows.item(0).mr;   alert(maxrowid); }); }); }  

i appreciate clarification regarding needs loaded select max(rowid) show correct max rowid value every time function called. standard format (structure) implementing max function? thanks.

have tried using order , limit?

select rowid mr surveys order rowid desc limit 1 

might work better you.


Comments

Popular posts from this blog

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -