4
如何在Android应用程序中联接两个SQLite表?
背景 我有一个Android项目,该项目的数据库包含两个表:tbl_question和tbl_alternative。 要使用问题和替代方法填充视图,我正在使用游标。在尝试连接两个表之前,获取所需数据没有任何问题。 Tbl_question ------------- _ID 题 分类ID Tbl_alternative --------------- _ID 问题ID 分类ID 另类 我想要以下内容: SELECT tbl_question.question, tbl_alternative.alternative where categoryid=tbl_alternative.categoryid AND tbl_question._id = tbl_alternative.questionid.` 这是我的尝试: public Cursor getAlternative(long categoryid) { String[] columns = new String[] { KEY_Q_ID, KEY_IMAGE, KEY_QUESTION, KEY_ALT, KEY_QID}; String whereClause = KEY_CATEGORYID + "=" + categoryid +" …