// Select the required "selectTable"
stmt = dba.newQueryStatement(selectTable, candidateAlias, clr);
// Join from the "selectTable" to the table of our candidate
ScalarExpression selectExpression = selectCandidateMapping.newScalarExpression(stmt, stmt.getMainTableExpression());
LogicSetExpression candidateTableExpression = stmt.newTableExpression(candidateTable, candidateTableIdentifier);
ScalarExpression candidateExpression = candidateTable.getIDMapping().newScalarExpression(stmt, candidateTableExpression);
if (allowNulls)
{
// Do LEFT OUTER JOIN since we need to allow nulls in the results
stmt.leftOuterJoin(selectExpression, candidateExpression, candidateTableExpression, true);