Count occurrence of a particular column value in sqlite, android? -



Count occurrence of a particular column value in sqlite, android? -

i have table in particular column has value repeated number of times. want calculate how many times occur.

let's database has column "select" repeated 5 times in table. how count it?

this code using

public string getcountselect() { string count = ""; string selectquery = "select count ( " + key_dealer_name + " ) " + table_dealer + " " + key_dealer_name + " = 'select'"; log.e("", selectquery); sqlitedatabase db = this.getwritabledatabase(); cursor cursor = db.rawquery(selectquery, null); if (cursor.movetofirst()) { { log.e("", cursor.getstring(cursor .getcolumnindex(key_dealer_name))); } while (cursor.movetonext()); } db.close(); homecoming count; }

try way

string selectquery = "select " + key_dealer_name + " " + table_dealer + " " + key_dealer_name + " = 'select'"; cursor cursor = db.rawquery(selectquery, null); int total_count=cursor.getcount();

cursor .getcount() method returns total affected rows.

android sqlite

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -