3

我在我的项目中使用 ActiveAndroid 作为 ORM 系统,我使用这行代码进行数据库查询

 List<Chats> s = new Select()
                .from(Chats.class)
                .where(col_conversation + " = ?  and " + col_sender + " = ? and " + col_body + " = ?",conversation.getId(),sender.getId(),body)    .execute();

但它获取 0 行作为结果。我确信我在数据库中有这样的行。

4

2 回答 2

6

另一种方法是使用多个where子句执行多参数查询:

List<Chats> s = new Select()
            .from(Chats.class)
            .where(col_conversation + " = ?",conversation.getId())
            .where(col_sender + " = ?", sender.getId())
            .where(body + " = ?", body)
            .execute();
于 2015-01-27T11:38:42.700 回答
2

您最不传递任何参数并将您的选择查询更改为以下内容:

List<Chats> s = new Select()
                .from(Chats.class)
                .where(col_conversation + " = " + conversation.getId() + " and " + col_sender + " = " + sender.getId() + " and " + col_body + " = '" + body + "'")

                .execute();
于 2015-01-27T11:34:43.067 回答