duplicate-table-alias
What it does
Section titled “What it does”Reports two tables of one FROM clause with the same alias, or the same name when there is no alias.
Why it matters
Section titled “Why it matters”A column reference with that alias can mean either table. Databases reject the query as ambiguous, or the query reads the wrong one.
To fix, give each table its own alias.
Example
Section titled “Example”...select distinct a from t;select a from t group by a;...select a from t as x join u as x on x.a = x.b;select a from t join u on t.a = u.a join t on t.a = t.b;select a from t join u on t.a = u.a join v on t.a = v.b;...with recursive r as (select 1 union all select n from r) select 2;Configuration
Section titled “Configuration”sql: lint: rules: duplicate-table-alias: warn # off, warn (default), errorEnabled by the presets: sql/sqlfluff.
Suppress one line with sudsy-disable-next-line duplicate-table-alias in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| sqlfluff | AL04 |
full |