gpt4 book ai didi

android - 如何在 GreenDao 中使用 GROUP BY

转载 作者:太空宇宙 更新时间:2023-11-03 13:46:50 26 4
gpt4 key购买 nike

我在 SO 中发现了与此问题相关的几个问题,但对我帮助不大。我想在 Android 中使用 GreenDao 库构建一个查询,查询应该按日期时间的降序获取包含特定电话号码的所有行,我还想按组名对它们进行分组。我的查询:

   List<activity> activities = activityDao.queryBuilder().where(Properties.Contact_number.eq(phonenumber)).orderDesc(Properties.Date_time).build().list();

如何在上述查询中包含 GROUP BY 以便按 group_name(我将 group_name 作为表中的列)对行进行分组?

我在GreenDao中没有找到任何GROUP BY方法,不确定我是否正确。

最佳答案

GreenDao 不支持

GROUP BY
你可以使用这个技巧:

where(new WhereCondition.StringCondition(Properties.Contact_number.eq(phonenumber) + "GROUP BY group_name")).orderDesc(Properties.Date_time).build().list();

它让您可以使用字符串构建您的 where 子句。

关于android - 如何在 GreenDao 中使用 GROUP BY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40573541/

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