java - JOOQ - nested query -


i'm trying write query jooq

select region.*,         (select count(*)         city          city.region_id = region.id) num region; 

i tried few things, no success. far got nothing more than

dsl.select().from(tables.region).fetch(); 

how can add num column result? appreciated.

your query this:

// how can select region.* dsl.select(region.fields())  // how can add more fields select clause    .select(  // nested selects select() (from dsl)         select(count())        .from(city)        .where(city.region_id.eq(region.id))  // how convert org.jooq.select field        .asfield("num")    )    .from(region)    .fetch(); 

the above implementation assuming static imports:

import static org.jooq.impl.dsl.*; import static path.to.generated.tables.*; 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -