gpt4 book ai didi

android - 我在此查询中得到 0 个结果。我究竟做错了什么? (安卓)

转载 作者:搜寻专家 更新时间:2023-10-30 22:36:27 24 4
gpt4 key购买 nike

我在 Android 上使用 SQLite。这是我的三个表:

String query = "create table " + TABLE_PERSON + " (" +
PERSON_COL_ID + " integer PRIMARY KEY AUTOINCREMENT, " +
PERSON_COL_NAME + " text, " +
PERSON_COL_SEX + " text CHECK (" + PERSON_COL_SEX + " IN ('M', 'F'))" +
");";
db.execSQL(query);

query = "create table " + TABLE_CONCEPT + " (" +
CONCEPT_COL_ID + " integer PRIMARY KEY AUTOINCREMENT, " +
CONCEPT_COL_NAME + " text, " +
CONCEPT_COL_DATE + " text " +
");";
db.execSQL(query);

query = "create table " + TABLE_DEBT + " (" +
DEBT_COL_ID + " integer PRIMARY KEY AUTOINCREMENT, " +
DEBT_COL_CONCEPT + " integer REFERENCES " + TABLE_CONCEPT + ", " +
DEBT_COL_CREDITOR + " integer REFERENCES " + TABLE_PERSON + ", " +
DEBT_COL_DEBTOR + " integer REFERENCES " + TABLE_PERSON + ", " +
DEBT_COL_ORIGAMT + " integer, " +
DEBT_COL_PAIDSOFAR + " integer, " +
DEBT_COL_DATEREPAID + " text" +
");";
db.execSQL(query);

插入 3 个人、2 个概念和 1 个债务后,进行以下查询后我得到 0 个结果:

  Cursor cur = databaseHelper.getDebtsByConcept(0);

执行的查询如下:

public Cursor getDebtsByConcept(int conceptID) {
String query = "select con.name, per1.name, per2.name, deb.origamt, deb.paidsofar, deb.daterepaid" +
" from " +
TABLE_PERSON + " per1, " + TABLE_PERSON + " per2, " + TABLE_CONCEPT + " con, " + TABLE_DEBT + " deb" +
" where deb.concept = " + conceptID +
" and con.id = deb.concept " +
" and per1.id = deb.creditorID" +
" and per2.id = deb.debtorID;";

Cursor res = db.rawQuery(query, null);
return res;
}

最佳答案

conecptID 值为 0 的数据库中不会有任何条目,同样的原因是您已在 concept table 中声明了 conceptID > 作为 Integer Auto Increment 所以当你插入第一个记录值时 conceptId 值将是 1,

您能否尝试在您的查询中传递 1,并且只是为了检查最初尝试使用 select * from ... 从数据库中获取所有记录。

关于android - 我在此查询中得到 0 个结果。我究竟做错了什么? (安卓),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37260770/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com