我花了很多时间来寻找解决方法,但我可以找到解决方案。
我正在尝试返回数据库中的总行数
这是我为了拉出特定类型的所有类型而采取的措施。
var film_list = tx.executeSql('SELECT * FROM mydb WHERE genre = "Comedy"');
我该怎么办
var film_total = tx.executeSql('SELECT * FROM mydb TOTAL_ROW_COUNT "');
console.log(film_total)
答案 0 :(得分:2)
您必须遍历每个表格,并将各个计数加起来。
SELECT Count(*) FROM TableName
答案 1 :(得分:1)
var totalRowCount = 0;
var genres = new Array("Comedy","Horror","Romantic","Action","Thriller","Indy");
for(var i = 0; i < genres.length; i++){
var cmdString ="SELECT COUNT(*) FROM mydb WHERE genre = '";
cmdString.concat(genres[i];
var genreCount = tx.executeSql(cmdString);
totalRowCount += genreCount;
}