这是我在数据库解决方案中的代码
public HashMap<String, String> getBookTheme(){
HashMap<String, String> hm = new HashMap<String, String>();
Cursor cursor = db.rawQuery("SELECT title, filepath FROM " +
BooksDBHelper.TABLE_BOOK + " INNER JOIN" + BooksDBHelper.TABLE_THEME +
" ON " + BooksDBHelper.TABLE_BOOK + " . " +
BooksDBHelper.KEY_BOK_ID + " = " + BooksDBHelper.TABLE_THEME +
" . " + BooksDBHelper.KEY_BOK_ID, null);
cursor.moveToLast();
if(cursor.getCount() != 0){
do{
hm.put("title", cursor.getString(cursor.getColumnIndex(BooksDBHelper.KEY_TITLE)));
hm.put("Theme", cursor.getString(cursor.getColumnIndex(BooksDBHelper.KEY_fILEPATH)));
}while(cursor.moveToNext());
}
return hm;
}
这是我的logcat错误
android.database.sqlite.SQLiteException: near "ON": syntax error (code 1): , while compiling: SELECT title, filepath FROM books INNER JOINtheme ON books . bookID = theme . bookID WHERE bookID != ?
请检查并告诉我一个收集语法。谢谢观看:))))
答案 0 :(得分:2)
JOIN和表1名称之间没有空格(“”)。表名和表之间有额外的空间。列名
将其更改为:
SELECT title, filepath FROM books INNER JOIN theme ON books.bookID = theme.bookID WHERE bookID != ?
我认为你没事。
希望这有帮助。