SQLite

View Ticket
Login
Ticket Hash: 3338b3fa19ac4abee6c475126a2e6d9d61f26ab1
Title: ambiguous column name when using multiple JOIN USING clauses and WHERE clause
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2011-10-31 18:46:16
Version Found In: 3.6.18
Description:
$ sqlite3
SQLite version 3.6.18
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE a (a INTEGER);
sqlite> CREATE TABLE b (a INTEGER);
sqlite> CREATE TABLE c (a INTEGER);
sqlite> SELECT * FROM a JOIN b USING (a);
sqlite> SELECT * FROM a JOIN b USING (a) JOIN c USING (a);
sqlite> SELECT * FROM a JOIN b USING (a) WHERE a = 1;
sqlite> SELECT * FROM a JOIN b USING (a) JOIN c USING (a) WHERE a = 1;
SQL error: ambiguous column name: a
sqlite> 

This bug was found while working on a class table inheritance plugin for the Sequel Ruby ORM.


drh added on 2011-10-13 14:44:54:
The column name is ambiguous. Does it mean a.a or b.a? The result is the same either way, but I don't expect the parser to know this.