I think all you're missing is just another join:
dslContext.select(ifd.IPADDRESS, d.NETWORKID, dl.PARENT)
.from(d)
.join(dl).on(dl.PARENT.equal(d.DESCID))
.join(ifd).on(dl.CHILD.equal(ifd.DESCID)) // another join here
.fetch();
Note, you can join as many tables as you want to form your own "table expression" to put in the FROM
clause in SQL. If you join three tables:
A join B on ...
join C on ...
What you're really doing is (pseudo-SQL):
T := A' join C on ...
A' := A join B on ...
So, the best way to read the above "triple-join" is:
SELECT ...
FROM ((A join B on ...) join C on ...)
The jOOQ API also supports nesting such JOIN
expressions natively, when using Table.join()
. For instance:
( A.join(B).on(...) ).join(C).on(...)
// A' --> ^^^^^^^^^^^^^^^^^^^^^
// T --> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The SelectJoinStep.join()
method you are using is mere convenience for the above Table.join()
This might be an interesting read for you, explaining 1-2 syntactic things in SQL.