我正在尝试使用以下INTERSECT查询来查询我的Android SQLite数据库,但它崩溃了。两个选择查询可以自己正常工作,它们肯定会产生匹配的结果,所以我无法理解为什么INTERSECT语句不起作用:
SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
Cursor cursor = db.rawQuery("SELECT tblsyndromes._id, synname" +
" FROM tblsyndromes JOIN tblsymsynlink ON tblsymsynlink.synId = tblsyndromes._id" +
" WHERE tblsymsynlink.symId = "+intCondition+" " +
" INTERSECT SELECT tblsyndromes._id, synname FROM tblsyndromes JOIN synconlink" +
" ON synconlink.synId = tblsyndromes._id" +
" WHERE synconlink.conId = "+intCondition2+"", null);
我正在使用的新代码 -
String sqlString = "SELECT tblsyndromes._id, tblsyndromes.synname FROM tblsyndromes JOIN synconlink ON synconlink.synId = tblsyndromes._id WHERE synconlink.conId = 55 INTERSECT SELECT tblsyndromes._id, tblsyndromes.synname FROM tblsyndromes JOIN tblsymsynlink ON tblsymsynlink.synId = tblsyndromes._id WHERE tblsymsynlink.symId = 136";
SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
Cursor cursor = db.rawQuery(sqlString,null);
ArrayList<String> mArrayList = new ArrayList<String>();
cursor.moveToFirst();
while(!cursor.isAfterLast()) {
mArrayList.add(cursor.getString(cursor.getColumnIndex("synname")));
cursor.moveToNext();
}
我已经使用sqlite3重复测试了sql并且它可以工作 - 两个选择查询在android中独立工作但是一旦我尝试使用INTERSECT我就崩溃了 - 我现在得到以下错误
字段0,-1的错误请求。 numRows = 3,numColumns = 2
答案 0 :(得分:-1)
public Long insert_todoinfo(String a, String b, String c, String d,
String e, String f, String g) {
// TODO Auto-generated method stub
ContentValues con = new ContentValues();
con.put("title", a);
con.put("description", b);
con.put("category", e);
con.put("due_date", c);
con.put("alarm_time", d);
con.put("alarm_set", f);
con.put("priority", g);
con.put("parform", "false");
return mDb.insert(DATABASE_TABLE_TODO_LIST, null, con);
}