在sqlite android中选择查询
发布时间:2020-12-12 19:00:09 所属栏目:百科 来源:网络整理
导读:String temp_address="nothing"; try { String selectQuery = "SELECT lastchapter FROM Bookdetails INTO"+temp_address+"WHERE bookpath=?"; db.execSQL(selectQuery,new String[] { fileName }); System.out.println(temp_address+" result of select Que
String temp_address="nothing"; try { String selectQuery = "SELECT lastchapter FROM Bookdetails INTO"+temp_address+"WHERE bookpath=?"; db.execSQL(selectQuery,new String[] { fileName }); System.out.println(temp_address+" result of select Query"); } catch(Exception e) { System.out.println(e+" is the error here"); } finally { db.close(); } logcat的 android.database.sqlite.SQLiteException: near "bookpath": syntax error:,while compiling: SELECT lastchapter FROM Bookdetails INTOnothingWHERE bookpath=? 我只想获取上述查询的结果,以便存储在lastchapter中的字符串在temp_address中可用 我是android sqlite数据库的新手,请帮忙 解决方法存在SQL语法问题,您需要使用Cursor来检索查询结果,例如使用rawQuery():String selectQuery = "SELECT lastchapter FROM Bookdetails WHERE bookpath=?"; Cursor c = db.rawQuery(selectQuery,new String[] { fileName }); if (c.moveToFirst()) { temp_address = c.getString(c.getColumnIndex("lastchapter")); } c.close(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |