SQLite:通过传递两个值来检索记录

时间:2012-04-07 06:16:59

标签: android sqlite

我有一个表“TABLE_QUESTION”。我需要通过传递 exam_id question_Id 来获取记录。我写了一个查询来从表中获取记录,但它显示异常"SQLite Exception near question_id"

以下是我的查询供您参考..

 String selectQuery=("select * from question where exam_id ='" + examId + " and question_id ='" + questionId +"'" );
        Cursor cursor = db.rawQuery(selectQuery, null);  

1 个答案:

答案 0 :(得分:4)

examId + "必须examId + " '

之后,您错过了一个单引号
String selectQuery=("select * from question where exam_id ='" + examId + "' and question_id ='" + questionId +"'" );