Bug #1759 derived tables
Submitted: 5 Nov 2003 10:16 Modified: 12 Nov 2003 5:44
Reporter: Giovanni MC Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1 OS:Windows (WINDOWS XP)
Assigned to: CPU Architecture:Any

[5 Nov 2003 10:16] Giovanni MC
Description:
I got error 1246: Every derived table must havs its own alias

Why?

How to repeat:
select intermedio.*,areas.wpx from 
(select estos.*, if(tipo=1,"No definido",if(tipo=2,"GRUPO",if(tipo=3,"EVENTUAL",if(tipo=4,"TITULAR",if(tipo=5,"SINDICALIZADO",if(tipo=6,"X",if(tipo=7,"",if(tipo=8,"","? ? ? ?")))))))) tipodescrip, if(otherid=0,'si','NO') Grupo, if(otherid>0,'si','NO') Camara from  (select gente.* from gntlmanctrl, (select 78 per, gntlman.* from gntlman left join gntlmanpp on gntlmanpp.per=78 and gntlmanpp.id=gntlman.id where gntlmanpp.id is null UNION select * from gntlmanpp where per=78) gente where gntlmanctrl.per=78 and gntlmanctrl.id=gente.id) estos) intermedio, 

((select wplaces.wp, wplaces.wpx from wplaces
 left join wplacespp on wplacespp.per=78 and wplacespp.wp=wplaces.wp where wplacespp.wp is null) UNION (select wp, wpx from wplacespp where per=78) order by wp) areas where intermedio.wp=areas.wp
[12 Nov 2003 5:44] Sergei Golubchik
because it is required by the standard:

<table primary> ::= <table or query name> [ [ AS ] <correlation name> ...
                    | <derived table> [ AS ] <correlation name> ...

as you can see an alias is NOT optional.