Skip to content

Right vs left join #588

@jakubvojacek

Description

@jakubvojacek

Hello @staabm

 public function rightLeftJoin(PDO $pdo): void
    {
        $stmt = $pdo->query('SELECT adaid from ada left join ak on adaid = eladaid');
        assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);

        $stmt = $pdo->query('SELECT adaid from ak right join ada on adaid = eladaid');
        assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);
    }

I found one RIGHT JOIN in our codebase that colleague of mine used (I've never used right join actually, always just left/inner).

Anyway, if I understand it right, I should be able to switch left vs right when I switch the table names an get same results, or not?

I tried that using the test above but it fails the 2nd assertion with

-'PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>'
+'PDOStatement<array{adaid: int<-32768, 32767>|null, 0: int<-32768, 32767>|null}>'

But I dont think that adaid will ever be null, or will it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions