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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -