Hello everyone,
I want to join twice between a project table and a user table.
Users can be attached to a project in the role as project leader or deputy.
So far I tried(and different versions):
var p = ProjectdbProject.PROJECTDB_PROJECT;
var pl = SecuritydbUser.SECURITYDB_USER;
int i = dbcontext.fetchCount(DSL.selectDistinct(p.ID)
.from(p)
.join(pl).on(p.FK_PROJECT_LEADER.eq(pl.ID))
.join(pl).on(p.FK_DEPUTY.eq(pl.ID))
.where(condition)
.groupBy(p.ID));
but the result was always this exception:
Caused by: org.postgresql.util.PSQLException: ERROR: table name "securitydb_user" specified more than once
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401) ~[postgresql-42.6.0.jar:42.6.0]
Any ideas?
Thanks alot!
I search in the master class book but could not find any example covering joining the same table twice.