I need to select the query from the database all the names that begin with the letter or letters, but without the letter "x".
For some titles that now exists in the following code(It's slow but it works):
String qstr = "SELECT SUM("+SQLhelper.COL_COUNT +") FROM " + SQLhelper.TABLE_MYDETAILS + " WHERE " +
SQLhelper.COL_DETAILID + " LIKE 'sh%'" +
" or " + SQLhelper.COL_DETAILID + " LIKE 'sw%'" +
" or " + SQLhelper.COL_DETAILID + " LIKE 'cty%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'twn%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'tlm%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'sp%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'rac%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'frnd%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'elf%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'pm%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'cas%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'oct%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'hp%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'njo%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'loc%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'stu%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'iaj%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'tlr%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'lor%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'ovr%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'tnt%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'pi%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'idea%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'min%'"+
" or " + SQLhelper.COL_DETAILID + " LIKE 'trn%'";
Cursor allc = db.rawQuery(qstr, null);
allc.moveToFirst();
int cnt = allc.getInt(0);
if(cnt==0) {
Toast.makeText(this, getResources().getString( R.string.myminifigsnotfound ), Toast.LENGTH_LONG).show();
return;
}
allc.close();
When I add other names must be added to the query string. I tried to do so, using regular expressions:
sql = "SELECT " + SQLhelper.COL_DETAILID + "," + SQLhelper.COL_COUNT + " FROM " + SQLhelper.TABLE_INSTRUCTIONS + " where " +SQLhelper.TABLE_INSTRUCTIONS_SETID + "="+setid + " and "+ SQLhelper.COL_DETAILID +" LIKE '[a-wyz]%'";
But it does not work, it returns an empty query. How to do it?
Aucun commentaire:
Enregistrer un commentaire