在我的应用程序中,我必须从数据库检索数据。我的要求是,我必须通过满足条件来检索数据,我必须将总计列的总和列列为家庭。Android中的数据库检索导致错误
我写了这个查询:
public String addhousehold()
{
long sum = 0;
Cursor cursor1 = db.rawQuery("SELECT SUM("+(KEY_TOTAL)+") FROM incomexpense WHERE groups=Income", null);
if(cursor1.moveToFirst())
{
sum = cursor1.getLong(0);
}
cursor1.close();
String housetotal=String.valueOf((long)sum);
System.out.println("house="+housetotal);
return housetotal;
}
但我得到一个错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.budget1/com.budget1.Report}:
android.database.sqlite.SQLiteException: no such column: Income: , while compiling: SELECT SUM(total) FROM incomexpense WHERE groups=Income.
As I am new to this please help me. Thanks in advance
是否检查过您的数据库表格,我认为它没有名为收入的列。 – 2012-07-10 07:55:50