Could someone explain to me, why this will work:
select t1.id, t1.age
from mytable t1
join (select age
from mytable
group by age) t2
on t1.age = t2.age
while using t1 in the second part of the join statement like so
select t1.id, t1.age
from mytable t1
join (select age
from t1
group by age) t2
on t1.age=t2.age
gives me an error?
ERROR 1146 (42S02) at line 17: Table '[...].t1' doesn't exist
In my actual problem, mytable corresponds to a selection, so I would like to use t1 in order avoid having to copy-paste the whole select ... from etc statement into the second part of the join statement.