final class JoinedTable
    implements Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A join of two table references with its ON condition or USING column list.

The structure follows the parse of the release, where a join can nest on the right without parentheses (t JOIN u JOIN v ON c joins t to the join of u and v in 8.0 and later). A natural join takes no condition and its right operand is no unparenthesized join; LEFT and RIGHT joins require a condition; a comma list as an operand is written in parentheses.

Rule: MYSQL-JOIN-001. The operands and the condition are derived by MYSQL-FROM-SCOPE-001 and combined by MYSQL-JOIN-COLUMNS-001. Source: https://dev.mysql.com/doc/refman/8.4/en/join.html. Status: Implemented.

Reading a joindoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT 1 FROM t LEFT JOIN u USING (a)');
    [$query->statement->from->operator, $query->statement->from->using[0]->value] // => [\SqlSemantics\Platform\MySql\Statement\Relation\Join\JoinOperator::Left, 'a']
Refusing a left join without a conditiondoctest
$t = new \SqlSemantics\Platform\MySql\Statement\Relation\TableReference(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('t')));
    $u = new \SqlSemantics\Platform\MySql\Statement\Relation\TableReference(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('u')));
    new \SqlSemantics\Platform\MySql\Statement\Relation\JoinedTable($t, \SqlSemantics\Platform\MySql\Statement\Relation\Join\JoinOperator::Left, $u) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public list<Name> $using
public Relation $left
public JoinOperator $operator
public Relation $right
public Scalar|null $on = null

Methods§

public function __construct(
    public Relation $left,
    public JoinOperator $operator,
    public Relation $right,
    public Scalar|null $on = null,
    list<Name> $using = [],
)

Parameters

$leftRelationThe left operand
$operatorJoinOperatorThe join operator
$rightRelationThe right operand
$onScalar|nullThe ON condition
$usinglist<Name>The USING columns
Calls 5
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the operands, the condition and the shape of the joined rows.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the operands, the operator and the condition.

Parameters

$outOutput
Calls 6

Test cases 8§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5
Other tests reaching this symbol 3

Relations§

Instantiated in 2
Type checks 3
Type declarations 7