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();
}
日志
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();
关于android - 在sqlite android中选择查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22169752/