Add a RAW JOIN string to the query.

@param $query
@param $constraint
@param $tableAlias

@return $this
180347
public function rawJoin($query, $constraint, $tableAlias)
    {
        $this->hasJoin = true;

        // Add table alias if present
        if (!is_null($tableAlias)) {
            $tableAlias = $this->quoteIdentifier($tableAlias);
            $query .= " {$tableAlias}";
        }

        // Build the constraint
        if (is_array($constraint)) {
            list($firstColumn, $operator, $secondColumn) = $constraint;
            $firstColumn = $this->quoteIdentifier($firstColumn);
            $secondColumn = $this->quoteIdentifier($secondColumn);
            $constraint = "{$firstColumn} {$operator} {$secondColumn}";
        }

        $this->joinSources[] = "{$query} ON {$constraint}";

        return $this;
    }
527391
public function full_outer_join($table, $constraint, $table_alias = null)
        {
            return $this->_addJoinSource("FULL OUTER", $table, $constraint, $table_alias);
        }
83506
public function leftJoin($table, $constraint, $tableAlias = null)
    {
        return $this->addJoinSource('LEFT', $table, $constraint, $tableAlias);
    }
322761
public function addTable($alias, $table, $condition = null, $joinType = 'LEFT', $prefix = null)
    {
        $tableStorage = [];

        $tableStorage['name'] = $table;
        $tableStorage['join'] = strtoupper($joinType);

        $condition = trim((string) new QueryElement('', (array) $condition, ' AND '));

        if (!$condition) {
            $tableStorage['join'] = 'FROM';
        }

        // Remove too many spaces
        $condition = preg_replace('/\s(?=\s)/', '', $condition);

        $tableStorage['condition'] = $condition;
        $tableStorage['prefix'] = $prefix;

        $this->tables[$alias] = $tableStorage;

        return $this;
    }
893868
public function Join(string $table, string $as, string $by, string $condition): QueryBuilder
    {
        $this->join[] = [
            'table' => $table,
            'as' => $as,
            'by' => $by,
            'cond' => $condition
        ];
        
        return $this;
    }
357104
public function union(SelectQuery $query): self
    {
        $this->union[] = ['', $query->build(false)];

        return $this;
    }
537767
protected function alreadyJoined(Builder $query, $table)
    {
        $joined = Arr::pluck((array) $query->getQuery()->joins, 'table');

        return in_array($table, $joined);
    }
916456
private function getJoinSql($baseTableAlias)
    {
        $joinSql           = '';
        $identifierColumns = $this->class->getIdentifierColumns($this->em);

        // INNER JOIN parent tables
        $parentClass = $this->class;

        while (($parentClass = $parentClass->getParent()) !== null) {
            $conditions = [];
            $tableName  = $parentClass->table->getQuotedQualifiedName($this->platform);
            $tableAlias = $this->getSQLTableAlias($parentClass->getTableName());
            $joinSql   .= ' INNER JOIN ' . $tableName . ' ' . $tableAlias . ' ON ';

            foreach ($identifierColumns as $idColumn) {
                $quotedColumnName = $this->platform->quoteIdentifier($idColumn->getColumnName());

                $conditions[] = $baseTableAlias . '.' . $quotedColumnName . ' = ' . $tableAlias . '.' . $quotedColumnName;
            }

            $joinSql .= implode(' AND ', $conditions);
        }

        // OUTER JOIN sub tables
        foreach ($this->class->getSubClasses() as $subClassName) {
            $conditions = [];
            $subClass   = $this->em->getClassMetadata($subClassName);
            $tableName  = $subClass->table->getQuotedQualifiedName($this->platform);
            $tableAlias = $this->getSQLTableAlias($subClass->getTableName());
            $joinSql   .= ' LEFT JOIN ' . $tableName . ' ' . $tableAlias . ' ON ';

            foreach ($identifierColumns as $idColumn) {
                $quotedColumnName = $this->platform->quoteIdentifier($idColumn->getColumnName());

                $conditions[] = $baseTableAlias . '.' . $quotedColumnName . ' = ' . $tableAlias . '.' . $quotedColumnName;
            }

            $joinSql .= implode(' AND ', $conditions);
        }

        return $joinSql;
    }
313482
public function aliasedColumn($query, $columnName, $tableName = null)
    {
        return $this->alias(
            $this->quoteColumn($columnName, $tableName),
            $this->quoteIdentifier(
                ($tableName ? $tableName . '_' : '') .
                $columnName
            )
        );
    }
564751
public static function select(string $tableAlias = null): Select
    {
        $select = new Select(static::getTableName(), $tableAlias);
        $select->setAdapter(static::getAdapterConnection());
        return $select;
    }
473641
public function rawSelectOne(Query $query, $join = 'all')
        {
            $query->setTable($this);
            $query->setupJoinTables($join);
            $query->setLimit(1);
            $query->generateSelectSQL();

            $resultset = Statement::getPreparedStatement($query)->execute();
            $resultset->next();

            return $resultset->getCurrentRow();
        }
166672
protected function setJoin(Query $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->relatedMap->getTable().'.'.$this->secondKey;

        $query->join($this->parentMap->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
    }
757419
protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className, $type)
    {
        $columnAlias = $this->getSQLColumnAlias($joinColumnName);

        $this->currentPersisterContext->rsm->addMetaResult('r', $columnAlias, $joinColumnName, false, $type);

        return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias;
    }
555575
public function innerJoin(string $tableName, string $tableAlias, string $condition) : self
    {
        $this->joins['inner'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition];

        return $this;
    }
920672
public function leftOuterJoin($table, $constraint, $tableAlias = null)
    {
        return $this->addJoinSource('LEFT OUTER', $table, $constraint, $tableAlias);
    }
626196
private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey)
    {
        $joinType = config('columnsortable.join_type', 'leftJoin');

        return $query->select($parentTable.'.*')->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey);
    }
907580
public function leftJoin(string $tableName, string $tableAlias, string $condition) : self
    {
        $this->joins['left'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition];

        return $this;
    }