Hi Kuro,

Thanks for your message and for following up with a possible solution.
Indeed, the TableLike.field(...) methods are the right way to extract a
column by name from any given table. Notice you don't necessarily need to
coerce the data type of "x" to String.class, in your example.

Thanks,
Lukas

On Tue, Dec 4, 2018 at 9:26 AM <[email protected]> wrote:

> I don't know this is the best way but this worked. (Please ignore "as y"
> in my original question. It wasn't needed.):
>
> Table<?> dyntable = table(select(cte1.field("x",
> String.class).from(cte).where(...).as("dyntable");
>
> Then to the main query's SELECT item list (i.e. within select()), I could
> add:
>
> dyntable.field("x")
>
>
>
> On Saturday, December 1, 2018 at 2:38:29 PM UTC-8,
> [email protected] wrote:
>>
>> I would like to construct the list of items to SELECT dynamically.
>> The Jooq manual in section 4.9 has this example:
>>
>> SelectField<?>[] select = {
>> AUTHOR.FIRST_NAME.concat(AUTHOR.LAST_NAME),
>> count()
>> };
>>
>> This works for a static table but how can we write a field of a dynamic
>> table like this?
>>
>> (SELECT x AS y FROM cte1) AS dyntable
>>
>> This is joined with other tables and I want to select dyntable's field y.
>>
>> Kuro
>>
>>
>> --
> 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