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

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -