Return the join clause.

@return string
975287
public function join($query)
    {
        $clause = '';
        $repository = $query->getRepository();
        $resources = $repository->getResources();
        $links = $resources->getLinks();
        foreach ($links as $link) {
            $type = strtoupper($link->resource->getLinkType());
            switch ($type) {
                case 'STRONG' : $type = 'INNER';break;
                case 'WEAK'   : $type = 'LEFT'; break;
            }
            $query->join($type, $link->resource->getName().' AS '.$this->_store->quoteName($link->resource->getAlias()), array(
                $link->child.'='.$link->parent,
            ));
        }

        $this->_links($query, $query->link);

        if (!empty($query->join)) {
            $joins = array();
            foreach ($query->join as $join) {
                $tmp = '';

                if (!empty($join['type'])) {
                    $tmp .= $join['type'].' ';
                }

                $tmp .= 'JOIN '.$join['resource'];
                $tmp .= ' ON '.implode(' AND ', $join['condition']);

                $joins[] = $tmp;
            }

            $clause = implode(' ', $joins);
        }

        return $clause;
    }
911061
protected function getDescriptionJoin()
    {
        $table = Registry::get(\OxidEsales\Eshop\Core\TableViewNameGenerator::class)->getViewName('oxarticles');
        $descriptionJoin = '';
        $searchColumns = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aSearchCols');

        if (is_array($searchColumns) && in_array('oxlongdesc', $searchColumns)) {
            $viewName = getViewName('oxartextends');
            $descriptionJoin = " LEFT JOIN $viewName ON {$viewName}.oxid={$table}.oxid ";
        }
        return $descriptionJoin;
    }
877157
public function getFields()
    {
        $joins = $this->_sql->getJoins();
        $fields = $this->_sql->getFields();

        if (!is_array($fields)) {
            return $fields;
        }

        if (count($joins) > 0 && $this->_sql->prefixTableName) {
            $table = $this->_sql->getTableName();
            foreach ($fields as $key => $field) {
                $fields[$key] = "{$table}.{$field}";
            }
        }

        return implode(', ', $fields);
    }
729363
public final function getJoined($tableName)
    {
        return isset($this->_joined[$tableName]) ? $this->_joined[$tableName] : null;
    }
597196
public function getTemplateJoined()
    {
        if (!empty($this->templateJoined)) {
            return $this->templateJoined;
        }
        $temp = [];
        foreach ($this->templateDirs as $item) {
            $temp[] = $item;
        }
        $joined = join(";", $temp);
        if (isset($joined[32])) {
            $joined = md5($joined);
        }
        $this->templateJoined = $joined;
        return $joined;
    }
312539
public function toString()
    {
        $this->parts = array();
        $this->params = array();
        $this->assemble();
        $this->query = join(' ', $this->parts);
        if( $this->interpolation ) {
            $this->interpolateParams();
        }
        return $this->query;
    }
1125878
public function asString()
    {
        $query = '';

        if (!empty($this->list)) {
            foreach ($this->list as $clause) {
                $query .= $clause->asString();
            }
        }

        return $query;
    }
202007
private function getSelectQuery()
	{
		$result = $this->getSelectClause();

		if ($join = $this->getJoinClause()) {
			$result .= ' ' . $join;
		}

		if ($where = $this->getWhereClause()) {
			$result .= ' ' . $where;
		}

		if ($groupBy = $this->getGroupByClause()) {
			$result .= ' ' . $groupBy;
		}

		if ($orderBy = $this->getOrderByClause()) {
			$result .= ' ' . $orderBy;
		}

		if ($limit = $this->getLimitClause()) {
			$result .= ' ' . $limit;
		}

		if ($offset = $this->getOffsetClause()) {
			$result .= ' ' . $offset;
		}

		return $result;
	}
1011415
private function _prepareJoin() 
	{
		$sQuery = '';

		if (is_array($this->_aJoin) && count($this->_aJoin) > 0) {

			foreach ($this->_aJoin as $sKey => $aValue) {

				if (isset($aValue['type']) && $aValue['type'] == 'left') {

					$sQuery .= " LEFT JOIN `".$aValue['table']."` ";
				}
				else {

					$sQuery .= " INNER JOIN `".$aValue['table']."` ";
				}

				if (isset($aValue['as']) && $aValue['as']) {

					$sQuery .= " AS ".$aValue['as']." ";
				}
				else {

					$sQuery .= " AS t".$this->_iAlias." ";
					$this->_iAlias++;
				}

				$sQuery .= " ON ".$aValue['left_field']." =  ".$aValue['right_field']." ";
			}
		}

		return $sQuery;
	}
349260
public function getRawQuery()
    {
        $sql = array();

        foreach ($this->getClauses() as $clause) {
            if (!$clause->isEmpty()) {
                $sql[] = $clause;
            }
        }

        return implode(' ', $sql);
    }
1251675
private function build_join( $join ) {
		$sql = '';
		if ( ! empty( $join ) ) {
			$items = [];
			foreach ( $join as $data ) {
				if ( ! is_array( $data ) || count( $data ) < 3 ) {
					continue;
				}
				$table = $data[0];
				$rule  = $data[1];
				$rule  = strtoupper( $rule );
				if ( ! in_array( $rule, [
					'JOIN',
					'INNER JOIN',
					'LEFT JOIN',
					'RIGHT JOIN',
				] ) ) {
					continue;
				}

				$conditions = $data[2];
				if ( empty( $conditions ) ) {
					continue;
				}
				$check = reset( $conditions );
				if ( ! is_array( $check ) ) {
					$conditions = [ $conditions ];
				}
				$values = [];
				foreach ( $conditions as $condition ) {
					if ( ! is_array( $condition ) || count( $condition ) < 3 ) {
						continue;
					}
					$left     = $condition[0];
					$op       = $condition[1];
					$right    = $condition[2];
					$values[] = $this->get_field_name( $left, null ) . " $op " . $this->get_field_name( $right, null );
				}
				if ( ! empty( $values ) ) {
					$as = null;
					if ( is_array( $table ) && count( $table ) > 1 ) {
						$as    = $table[1];
						$table = $table[0];
					}
					$items[] = $rule . ' ' . $this->get_table( $table ) . ( isset( $as ) ? " AS $as" : '' ) . ' ON ' . implode( ' AND ', $values );
				}
			}
			if ( ! empty( $items ) ) {
				$sql .= ' ' . implode( ' ', $items );
			}
		}

		return $sql;
	}
211098
public function getQuery()
    {
        $joins = empty($this->joins) ? '' : implode(' ', $this->joins);
        $where = empty($this->where) ? '' : 'WHERE '.implode(' AND ', $this->where);
        $sort = empty($this->sortBy) ? '' : 'ORDER BY '.implode(', ', $this->sortBy);
        $limit = is_null($this->page) ? '' : 'LIMIT ' . $this->page .',' .$this->length;
        $group = empty($this->group) ? '' : 'GROUP BY ' . implode(', ', $this->group);
        
        $query = sprintf(
            'SELECT %s FROM %s %s %s %s %s %s;',
            $this->select,
            $this->from,
            $joins,
            $where,
            $group,
            $sort,
            $limit
        );
        
        return str_replace('  ', ' ', $query);
    }
44043
public function getSPARQL() {
		// add subqueries to the beginning because they are logically evaluated first
		$sparql = $this->formatSubqueries();

		foreach ( $this->conditions as $subject => $predicates ) {
			$sparql .= ' ' . $subject;
			$sparql .= $this->formatPredicates( $predicates ) . ' .';
		}

		$sparql .= $this->formatOptionals();
		$sparql .= $this->formatFilters();
		$sparql .= $this->formatUnions();

		return $sparql;
	}
545773
function _join() {
    var sql = '',
        i = -1,
        joins = this.grouped.join;
    if (!joins) {
      return '';
    }
    while (++i < joins.length) {
      var join = joins[i];
      if (i > 0) {
        sql += ' ';
      }
      if (join.joinType === 'raw') {
        sql += this.formatter.unwrapRaw(join.table);
      } else {
        sql += join.joinType + ' join ' + this.formatter.wrap(join.table);
        var ii = -1;
        while (++ii < join.clauses.length) {
          var clause = join.clauses[ii];
          sql += ' ' + (ii > 0 ? clause[0] : clause[1]) + ' ';
          sql += this.formatter.wrap(clause[2]);
          if (clause[3]) {
            sql += ' ' + this.formatter.operator(clause[3]);
          }
          if (clause[4]) {
            sql += ' ' + this.formatter.wrap(clause[4]);
          }
        }
      }
    }
    return sql;
  }
1239921
public function findAllJoinPage()
    {
        $qb = $this->createQueryBuilder('m');
        $qb->select('m,p');
        $qb->leftJoin('m.page', 'p');

        return $qb->getQuery()->execute();
    }
1023410
public function render_join()
    {
        if (!$this->args['join']) {
            return '';
        }
        $joins = array();
        foreach ($this->args['join'] as $j) {
            $jj = '';

            $jj .= $j['t'].' join ';

            $jj .= $this->bt($j['f1']);

            if (!is_null($j['fa'])) {
                $jj .= ' as '.$this->bt($j['fa']);
            }

            $jj .= ' on ';

            if ($j['expr']) {
                $jj .= $this->consume($j['expr']);
            } else {
                $jj .=
                    $this->bt($j['fa'] ?: $j['f1']).'.'.
                    $this->bt($j['f2']).' = '.
                    $this->bt($j['m1']).'.'.
                    $this->bt($j['m2']);
            }
            $joins[] = $jj;
        }

        return implode(' ', $joins);
    }
1151359
public static function join()
    {
        $arguments = func_get_args();

        if (func_get_args() === 1 and is_array($arguments[ 0 ])) {
            $arguments = $arguments[ 0 ];
        }

        foreach ($arguments as $key => $argument) {
            $arguments[ $key ] = Str::removeRight($arguments[ $key ], '/');

            if ($key > 0) {
                $arguments[ $key ] = Str::removeLeft($arguments[ $key ], '/');
            }
        }

        return implode(DIRECTORY_SEPARATOR, $arguments);
    }