Android 带 AND 的 sqlite 查询

Android sqlite Query with AND

我想问一下你是如何进行这样的查询的:

select * from table where id = 1 AND year = 1999

用Android中sqlite的命令查询? 提前致谢

只需将"AND"添加到第3个参数(String selection):

database.query(TABLE_NAME, new String[]{COLUMN_1, COLUMN_2},
               COLUMN_1 + " = ? AND " + COLUMN_2 + " = ? ", new String[]{value1, value2}, null, null, null);

在你的情况下,COLUMN_1idCOLUMN_2yearvalue1"1"value2"1999".