Hello,

I'd like to write something like
select 
    b.id,b.title,
    a.id,a.name,
    r.id,r.name
from book b
join person a on a.id=b.author_id
left join person r on r.id=b.reviewer_id

I found the documentation 
http://www.jooq.org/doc/3.2/manual/sql-building/table-expressions/aliased-tables/
 
and wrote
Book b = BOOK.as("b");
Person a = PERSON.as("a");
Person r = PERSON.as("r");
create.select(
    b.field("ID"),b.field("TITLE"),
    a.field("ID"),a.field("NAME"),
    r.field("ID"),r.field("NAME")
    ).from(b)
    .join(a).on(a.ID.equal(b.AUTHOR_ID))
    .leftJoin(r).on(r.ID.equal(b.REVIEWER_ID))

But then fields are not type safe,  and column names are just strings. Is 
it possible to write something like:
create.select(
    b.id,b.title,
    a.id,a.name,
    r.id,r.name
    ).from(b)
    .join(a).on(a.ID.equal(b.AUTHOR_ID))
    .leftJoin(r).on(r.ID.equal(b.REVIEWER_ID))

Thanks,
Gérald

-- 
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/groups/opt_out.

Reply via email to