java - Selecting conditions with jooq -


in sql, can execute query of type:

select cost > 1000 above_k, name products; 

giving me list:

+---------+--------+ | above_k | name   | +---------+--------+ | true    | gold   | | false   | silver | +---------+--------+ 

how can model similar query using jooq? cannot (obviously):

ctx.select(tables.products.cost.gt(1000)) 

since, there no method select(condition condition). or if wanted to:

select cost*0.9 discounted_cost products; 

is there way using jooq?

sql 1:

select cost > 1000 above_k, name  products; 

jooq 1:

ctx.select(field(products.cost.gt(1000)).as("above_k"), products.name)    .from(products)    .fetch(); 

see dsl.field(condition)

sql 2:

select cost*0.9 discounted_cost  products; 

jooq 2:

ctx.select(products.cost.mul(0.9).as("discounted_cost"))    .from(products)    .fetch(); 

see field.mul(number) or field.multiply(number)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -