Hi Mark

I'm assuming you have a reason for not using an OR predicate... Yes, it's
possible

ctx.selectFrom(FOO)
   .where(FOO.USER_NAME.like("%mark%")
   .union(selectFrom(FOO)
   .where(FOO.USER_NAME.like("%greg%"))
   .limit(1)
   .fetchOne();

I'm not sure why you're calling Select.union() instead of
SelectUnionStep.union()...
https://www.jooq.org/javadoc/latest/org/jooq/SelectUnionStep.html

Hope this helps,
Lukas

On Fri, Jan 18, 2019 at 6:11 AM Mark Derricutt <[email protected]> wrote:

> Hey all,
>
> Is it possible in Jooq to generate something like the following:
>
> (select * from foo where user_name  like '%mark%' union select * from foo 
> where user_name  like '%greg%') limit 1;
>
> .union() on Jooq's Select class just returns another Select which doesn't
> seem to have a .limit() function, there is org.jooq.ResultQuery#maxRows
> but that ( according to the java doc ) doesn't produce a LIMIT clause...
>
> Ideally, I want to call something like:
>
> select.limit(1).fetchOptional().map(....)
>
> without going into a stream().findFirst() and worrying about leaky
> connections from streams...
>
> Is this possible at all?
>
> Cheers
> Mark
> ------------------------------
>
> "The ease with which a change can be implemented has no relevance at all
> to whether it is the right change for the (Java) Platform for all time." —
> Mark Reinhold.
>
> Mark Derricutt
> http://www.theoryinpractice.net
> http://www.chaliceofblood.net
> http://plus.google.com/+MarkDerricutt
> http://twitter.com/talios
> http://facebook.com/mderricutt
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to