如果我将一个数字硬编码到 where 部分,我会得到我期望的行
Cursor cursor = db.query( tableName,
new String[] {colID, colString, colNumber },
colNumber + "=14",
null,
null, null, null, null);
如果我将数字作为参数输入,则不会返回任何行。
Cursor cursor = db.query( tableName,
new String[] {colID, colString, colNumber },
colNumber + "=?",
new String[] { String.valueOf(14) },
null, null, null, null);
在第二种情况下我做错了什么?
创建表语句:
db.execSQL("CREATE TABLE "
+ otherTableName + " ("
+ otherTableID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ otherTableString + " TEXT"
+ ");");
db.execSQL("CREATE TABLE "
+ tableName + " ("
+ colID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ colString + " TEXT, "
+ colNumber + " REFERENCES "
+ otherTableName + "(" + otherTableID
+ "));");