select another table to join on (implicit INNER JOIN)
773486
public function join(
		string $table, 
		string $match, 
		string $against
	) {
		// secure parameters
		list($table) 	= Query\Convert::columnToPlaceholder($this->Quote ,$table);
		list($match) 	= Query\Convert::columnToPlaceholder($this->Quote ,$match);
		list($against) 	= Query\Convert::columnToPlaceholder($this->Quote ,$against);
		// push the join condition
		$this->Joins[] = "JOIN {$table} ON {$match} = {$against}";
		// return self to the next method
		return $this;
	}
835192
private void tableJoins(String pColumn, boolean pWhereJoin) {
        String join = null;
        String table = null;
	    
        if (pColumn == null) {
            // Identity
            join = getIdentityJoin();
            table = getTable(getProperty(getPrimaryKey()));
        }
        else {
            // Normal
            int dotIndex = -1;
            if ((dotIndex = pColumn.lastIndexOf(".")) <= 0) {
                // No table qualifier
                return;
            }
	    
            // Get table qualifier.
            table = pColumn.substring(0, dotIndex);
	    
            // Don't care about the tables that are not supposed to be selected from
            String property = (String) getProperty(pColumn);
	    
            if (property != null) {
                String mapType = (String) mMapTypes.get(property);
                if (!pWhereJoin && mapType != null && !mapType.equals(DIRECTMAP)) {
                    return;
                }

                join = (String) mJoins.get(property);    
            }	
        }

        // If table is not in the tables Hash, add it, and check for joins.
        if (mTables.get(table) == null) {
            if (join != null) {
                mTables.put(table, join);
		
                StringTokenizer tok = new StringTokenizer(join, "= ");
                String next = null;
		
                while(tok.hasMoreElements()) {
                    next = tok.nextToken();
                    // Don't care about SQL keywords
                    if (next.equals("AND") || next.equals("OR") 
                        || next.equals("NOT") || next.equals("IN")) {
                        continue;
                    }
                    // Check for new tables and joins in this join clause.
                    tableJoins(next, false);
                }
            }
            else {
                // No joins for this table.
                join = "";
                mTables.put(table, join);
            }
        }    
    }
95485
def _run_select(self):
        
        return self._connection.select(
            self.to_sql(), self.get_bindings(), not self._use_write_connection
        )
973667
function (type, table, expr, tableAlias) {
            tableAlias = tableAlias || {};
            if (type === "cross" && !isUndefinedOrNull(expr)) {
                type = "inner";
            }
            if (type === "fullOuter") {
                throw new QueryError("MySQL does not support FULL OUTER JOIN");
            }
            return this._super(arguments, [type, table, expr, tableAlias]);
        }
109921
public static function inner(Table $table, string $alias, array $on) : Join
    {
        return new self(self::INNER, $table, $alias, $on);
    }
1134164
public function innerJoin($table, $alias = null, $on = null)
    {
        return $this->join($table, $alias, $on, 'INNER JOIN');
    }
1174915
public function join($table, $column = null, $operator = null, $value = null) {
        $this->q->apd(' INNER JOIN ' . $table);

        if (!empty($column) || !empty($operator) || !empty($value)) {
            if (in_array($operator, $this->operators)) {
                $this->q->apd(' ON ' . $column . $operator . ' ' .  $value);
            } else {
                $value = '=';
                $this->q->apd(' ON ' . $column . ' ' . $value . ' ' . $operator);
            }

            return $this;
        } else {
            return $this;
        }
    }
425715
public function innerJoin(string $table, $firstTableField, string $operator = null, string $secondTableField = null): Select
    {
        $this->joins[] = [
          'type' => 'INNER JOIN',
          'table' => $table,
          'first' => $firstTableField,
          'operator' => $operator,
          'second' => $secondTableField
        ];
        return $this;
    }
123323
def _set_join(self, query=None):
        
        if not query:
            query = self._query

        foreign_key = '%s.%s' % (self._related.get_table(), self._second_key)

        query.join(self._parent.get_table(), self.get_qualified_parent_key_name(), '=', foreign_key)
1207176
public function innerJoin($table, string $on = null, string ...$params)
    {
        $this->join('INNER', null, $table, $on, $params);

        return $this;
    }
239551
function performJoining (sourceData, joinSet, joinArgs) {
        var length = joinSet.length,
            i,
            rightKeyAccessors = [];

        joinArgs.rightKeyPropertyPaths.forEach(function (keyValue) {
            rightKeyAccessors.push(getKeyValueAccessorFromKey(keyValue));
        });

        for (i = 0; i < length; i += 1) {
            var rightRecord = joinSet[i],
                currentBin = joinArgs.keyHashBin;

            if (isNullOrUndefined(rightRecord)) {
                continue;//move onto the next, can't join on records that don't exist
            }

            //for each entry in the join set add it to the source document at the correct index
            rightKeyAccessors.forEach(function (accessor) {
                currentBin = currentBin[accessor(rightRecord)];
            });

            currentBin.forEach(function (sourceDataIndex) {
                var theObject = sourceData[sourceDataIndex][joinArgs.newKey];

                if (isNullOrUndefined(theObject)) {//Handle adding multiple matches to the same sub document
                    sourceData[sourceDataIndex][joinArgs.newKey] = rightRecord;
                } else if (Array.isArray(theObject)) {
                    theObject.push(rightRecord);
                } else {
                    sourceData[sourceDataIndex][joinArgs.newKey] = [theObject, rightRecord];
                }
            });
        }
    }
166024
def select(self, to_select, where=None, sql_params=None):
        '''
        
        '''
        if sql_params is None:
            sql_params = []
        query = '''
        SELECT %s FROM %s
        ''' % (to_select, self._name)
        if where:
            query = '%s WHERE %s' % (query, where)
        return self._cursor.execute(query, tuple(sql_params))
763085
protected void appendTableWithJoins(TableAlias alias, StringBuffer where, StringBuffer buf)
    {
        int stmtFromPos = 0;
        byte joinSyntax = getJoinSyntaxType();

        if (joinSyntax == SQL92_JOIN_SYNTAX)
        {
            stmtFromPos = buf.length(); // store position of join (by: Terry Dexter)
        }

        if (alias == getRoot())
        {
            // BRJ: also add indirection table to FROM-clause for MtoNQuery 
            if (getQuery() instanceof MtoNQuery)
            {
                MtoNQuery mnQuery = (MtoNQuery)m_query; 
                buf.append(getTableAliasForPath(mnQuery.getIndirectionTable(), null).getTableAndAlias());
                buf.append(", ");
            }           
            buf.append(alias.getTableAndAlias());
        }
        else if (joinSyntax != SQL92_NOPAREN_JOIN_SYNTAX)
        {
            buf.append(alias.getTableAndAlias());
        }

        if (!alias.hasJoins())
        {
            return;
        }

        for (Iterator it = alias.iterateJoins(); it.hasNext();)
        {
            Join join = (Join) it.next();

            if (joinSyntax == SQL92_JOIN_SYNTAX)
            {
                appendJoinSQL92(join, where, buf);
                if (it.hasNext())
                {
                    buf.insert(stmtFromPos, "(");
                    buf.append(")");
                }
            }
            else if (joinSyntax == SQL92_NOPAREN_JOIN_SYNTAX)
            {
                appendJoinSQL92NoParen(join, where, buf);
            }
            else
            {
                appendJoin(where, buf, join);
            }

        }
    }
448442
def visit_select(self, select, asfrom=False, parens=True,
                     fromhints=None,
                     compound_index=0,
                     nested_join_translation=False,
                     select_wraps_for=None,
                     **kwargs):
        jsn = {'command': 'advanced/search', 'type': 'select'}
        needs_nested_translation = \
            select.use_labels and \
            not nested_join_translation and \
            not self.stack and \
            not self.dialect.supports_right_nested_joins

        if needs_nested_translation:
            transformed_select = self._transform_select_for_nested_joins(
                select)
            text = self.visit_select(
                transformed_select, asfrom=asfrom, parens=parens,
                fromhints=fromhints,
                compound_index=compound_index,
                nested_join_translation=True, **kwargs
            )

        toplevel = not self.stack
        entry = self._default_stack_entry if toplevel else self.stack[-1]

        populate_result_map = toplevel or \
                              (
                                  compound_index == 0 and entry.get(
                                      'need_result_map_for_compound', False)
                              ) or entry.get('need_result_map_for_nested',
                                             False)

        # this was first proposed as part of #3372; however, it is not
        # reached in current tests and could possibly be an assertion
        # instead.
        if not populate_result_map and 'add_to_result_map' in kwargs:
            del kwargs['add_to_result_map']

        if needs_nested_translation:
            if populate_result_map:
                self._transform_result_map_for_nested_joins(
                    select, transformed_select)
            return jsn

        froms = self._setup_select_stack(select, entry, asfrom)

        column_clause_args = kwargs.copy()
        column_clause_args.update({
            'within_label_clause': False,
            'within_columns_clause': False
        })

        if select._hints:
            hint_text, byfrom = self._setup_select_hints(select)
            if hint_text:
                text += hint_text + " "
        else:
            byfrom = None


        
        if select._distinct:
            jsn['distinct'] = True

        # the actual list of columns to print in the SELECT column list.
        inner_columns = [
            c for c in [
                self._label_select_column(
                    select,
                    column,
                    populate_result_map, asfrom,
                    column_clause_args,
                    name=name)
                for name, column in select._columns_plus_names
                ]
            if c is not None
            ]

        if populate_result_map and select_wraps_for is not None:
            # if this select is a compiler-generated wrapper,
            # rewrite the targeted columns in the result map
            wrapped_inner_columns = set(select_wraps_for.inner_columns)
            translate = dict(
                (outer, inner.pop()) for outer, inner in [
                    (
                        outer,
                        outer.proxy_set.intersection(wrapped_inner_columns))
                    for outer in select.inner_columns
                    ] if inner
            )
            self._result_columns = [
                (key, name, tuple(translate.get(o, o) for o in obj), type_)
                for key, name, obj, type_ in self._result_columns
                ]

        jsn = self._compose_select_body(
            jsn, select, inner_columns, froms, byfrom, kwargs)

        if select._statement_hints:
            per_dialect = [
                ht for (dialect_name, ht)
                in select._statement_hints
                if dialect_name in ('*', self.dialect.name)
                ]
            if per_dialect:
                text += " " + self.get_statement_hint_text(per_dialect)

        if self.ctes and self._is_toplevel_select(select):
            text = self._render_cte_clause() + text

        if select._suffixes:
            text += " " + self._generate_prefixes(
                select, select._suffixes, **kwargs)

        self.stack.pop(-1)

        if asfrom and parens:
            return jsn  # "(" + text + ")"
        else:
            return jsn
1265109
public function join($table, $on = null, $where = null, $binds = [], $type = 'LEFT')
    {
        if ($table instanceof Relation) {
            if (is_only_callable($on)) {
                /**
                 * Is this needed?
                 */
                Reflect::call($on, [$table, $table->getQuery()]);
            }

            $table->mergeToQuery($this->getQuery());
        } elseif ($table instanceof Entity) {
            $query = $table->getQuery();

            $sql = $query->buildSQL();

            $this->getQuery()->join(
                $type . ' JOIN (' . $sql . ') AS `' . $where . '` ON (' .
                (strpos($on, '(') ? '' : ($where . '.')) . $on . ')',
                null,
                null,
                $query->buildBinds()
            );
        } else {
            $this->getQuery()->join($table, $on, $where, $binds);
        }

        return $this;
    }
991959
public function join($table, $criteria = null, $type = self::INNER_JOIN, $alias = null)
    {
        if (!$this->isJoinUnique($table, $alias)) {
            return $this;
        }

        if (is_string($criteria)) {
            $criteria = array($criteria);
        }

        $this->join[] = array('table' => $table,
            'criteria' => $criteria,
            'type' => $type,
            'alias' => $alias);

        return $this;
    }
1158913
@Override
    public <E> List<E> getColumnsById(String schemaName, String joinTableName, String joinColumnName,
            String inverseJoinColumnName, Object parentId, Class columnJavaType)
    {
        StringBuffer sqlQuery = new StringBuffer();
        sqlQuery.append("SELECT ").append(inverseJoinColumnName).append(" FROM ")
                .append(getFromClause(schemaName, joinTableName)).append(" WHERE ").append(joinColumnName).append("='")
                .append(parentId).append("'");

        Session s = getSession();

        SQLQuery query = s.createSQLQuery(sqlQuery.toString());

        List<E> foreignKeys = new ArrayList<E>();

        foreignKeys = query.list();

        return foreignKeys;
    }