Add count as select field using jooq SelectQuery

扶醉桌前 提交于 2019-12-11 01:44:18

问题


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

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.


回答1:


Just use DSL.count()

query.addSelect(count());

The above is assuming a static import as such:

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


来源:https://stackoverflow.com/questions/19849839/add-count-as-select-field-using-jooq-selectquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!