我有三个表,我想用 sql 语句进行查询,但它不能很好地工作,因为它没有给我所有可能的结果......
编码:
public void setsuchresultat(String pSearchword)
{
String[] table = new String[]{"tbl_A", "tbl_B", "tbl_C"};
String[] column = new String[]{"columnA", "columnB" }; // Type varchar(50) not null
String[] search = new String[]{"%" + pSearchword+ "%", pSearchword+ "%", "%" + pSearchword, pSearchword};
getdata(table,column,search);
}
public void getdata(String[] pTable, String[] pColumn, String[] pSearch)
{
for(String t:pTable)
{
for(String s : pColumn)
{
for(String k : pSearch)
{
Cursor c = this.db.rawQuery("SELECT * FROM " + t + " WHERE " + s + " LIKE '"+ k + "'", null);
if ((c.moveToFirst()) || c.getCount() > 0)
{
while(c.moveToNext())// Suchresultat abspeichern
{
String col1 = c.getString(c.getColumnIndex("columnA"));
String col2 = c.getString(c.getColumnIndex("columnB"));
}
}
}
}
}
}