Skip to content

right-join

SQLstyleno fixdefault: offsql/sqlfluff

Reports a RIGHT join.

Most queries read from left to right and join the next table onto what came before. A right join makes the reader turn that around, and the same result is a LEFT JOIN with the tables in the other order.

To fix, swap the tables and use LEFT JOIN.

Reported
...
select 1 union distinct select 2;
...
select a from t right join u on t.a = u.a;
select a from t left join u on t.a = u.a;
...
sql:
lint:
rules:
right-join: warn # off (default), warn, error

Enabled by the presets: sql/sqlfluff.

Suppress one line with sudsy-disable-next-line right-join in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
sqlfluff CV08 full