"SELECT MAX(rowid) FROM table" query works only after "SELECT * FROM
table" has been called
The below function is in a javascript file. The intent is to return the
maximum value in the rowid column of a sqlite database. Currently, it
works only after a "Select * from table query" has been run. Why is this?
function lastRecord(){
db.transaction(function (tx) {
tx.executeSql('SELECT MAX(rowid) as mr FROM Surveys', [],
function(tx, results){
var maxRowid = results.rows.item(0).mr;
alert(maxRowid);
});
});
}
I would appreciate clarification regarding what needs to be loaded to get
SELECT MAX(rowid) to load. What is the standard format (structure) for
implementing the MAX function? THANKS.
No comments:
Post a Comment