I have the following code in Android Studio
String[] buildquery={
"SELECT anatomia FROM "+usuariosinfodbh.tablausuarioname+" WHERE anatomia='si' AND usuario='"+nombre+"';",
"SELECT bioquimica FROM "+usuariosinfodbh.tablausuarioname+" WHERE bioquimica='si' AND usuario='"+nombre+"';",
"SELECT histologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE histologia='si' AND usuario='"+nombre+"';",
"SELECT fisiologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE fisiologia='si' AND usuario='"+nombre+"';",
"SELECT embriologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE embriologia='si' AND usuario='"+nombre+"';",
"SELECT microbiologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE microbiologia='si' AND usuario='"+nombre+"';",
"SELECT urgencias FROM "+usuariosinfodbh.tablausuarioname+" WHERE urgencias='si' AND usuario='"+nombre+"';",
"SELECT farmacologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE farmacologia='si';",
"SELECT nutricion FROM "+usuariosinfodbh.tablausuarioname+" WHERE nutricion='si' AND usuario='"+nombre+"';",
"SELECT patologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE patologia='si' AND usuario='"+nombre+"';",
"SELECT fisiopatologia FROM "+usuariosinfodbh.tablausuarioname+" WHERE fisiopatologia='si' AND usuario='"+nombre+"';"
};
SQLiteQueryBuilder qb=new SQLiteQueryBuilder();
String query=qb.buildUnionQuery(buildquery, null, null);
Cursor c= db.rawQuery(query, null);
When I run this with the pertinent Log.d to know how many columns are being selected, it shows me only 1, which is the first column where the condition is met (which is anatomia='si' in this case). I know it is the first one becase if I remove the SELECT... where anatomia='si', then it the Log.d prints nutricion='si', which is the next condition that is true. I want this code to select ALL the columns where the condition I set is fullfilled, not just the first that meets it. Thank you in advance. PS: (Log.d)s I'm using are:
Log.d("countcolumsreg", Integer.toString(c.getCount()));//0
Log.d("countcolumns", Integer.toString(c.getColumnCount()));//0
and
String[] usuariomaterias= new String[c.getColumnCount()];
for (int i=0; i<c.getColumnCount();i++) {
usuariomaterias[i] = c.getColumnName(i);
Log.d("arrayseg",usuariomaterias[i]); //anatomia
}
Aucun commentaire:
Enregistrer un commentaire