Bug #1483 Using subqueries, I get a misleading "table not found" error
Submitted: 4 Oct 2003 17:41 Modified: 2 Nov 2003 7:35
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:MySQL 4.1.1 OS:Linux (SuSE 8.2)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[4 Oct 2003 17:41] Peter Gulutzan
Description:
Table x exists, but column x.y does not exist. 
If I use the column reference x.y in a certain 
context (group by within subquery), I receive 
the error message "Unknown table ...". 
 
But the table is known. It's the column that's unknown. 
 

How to repeat:
create table t1 (s1 int); 
create table t2 (s1 int); 
insert into t1 values (1); 
insert into t1 values (2); 
select * from t1 where (select count(*) from from t2 group by t1.s2) = 1; 
 
Result: "Unknown table 't1' in group statement" 
 

Suggested fix:
A better error message would be: 
Result: "Unknown column 't1.s2' in group clause"
[10 Oct 2003 20:53] MySQL Verification Team
Assigned to Sanja.

Peter: your test case has the below line wrong:

select * from t1 where (select count(*) from from t2 group by t1.s2) = 1;
                                        ^^^^^^^^^
but removing the second "from" I got your error reported. :)
[11 Oct 2003 7:43] Oleksandr Byelkin
ChangeSet 
  1.1591 03/10/11 17:41:15 bell@laptop.sanja.is.com.ua +3 -0 
  more resonable errors about name resolving in subqueries (BUG#1483)
[2 Nov 2003 7:35] Oleksandr Byelkin
Thank You for bugreport. Bugfix is pushed into source repository.