简体   繁体   English

使用jooq SelectQuery将计数添加为选择字段

[英]Add count as select field using jooq SelectQuery

Most of the existing posts I can find dealing with my learning jook are outdated. 我发现与我的学习恶作剧有关的大多数现有帖子已过时。

I'm trying to build dynamically so that I can use conditions for certain changes. 我正在尝试动态构建,以便可以使用条件进行某些更改。 I'm trying to find how to add COUNT(*) to an existing list of fields 我试图找到如何将COUNT(*)添加到现有字段列表中

SelectQuery query = create().selectQuery();
query.addSelect(TABLE.FIELD);
// add COUNT(*)?

I'm not seeing any methods or API help on how to do this when building the query dynamically. 动态构建查询时,我看不到任何方法或API帮助。

Just use DSL.count() 只需使用DSL.count()

query.addSelect(count());

The above is assuming a static import as such: 上面假设静态导入是这样的:

import static org.jooq.impl.DSL.*;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM