I'm running this query on MySQL
SELECT ID FROM ( SELECT ID, msisdn FROM ( SELECT * FROM TT2 ) );
It gives this error:
Each derived table must have its own alias.
What causes this error?
P粉5452181852023-10-11 18:53:28
I think it requires you to do this:
SELECT ID FROM (SELECT ID, msisdn FROM (SELECT * FROM TT2) as myalias ) as anotheralias;
But why are you writing this query in the first place?
P粉7294365372023-10-11 17:33:00
Each derived table (also called a subquery) does have to have an alias. ie. Each query within parentheses must specify an alias (ASwhat
) that can be used to reference it in the rest of the outer query.
SELECT ID FROM ( SELECT ID, msisdn FROM ( SELECT * FROM TT2 ) AS T ) AS T
Of course, in your case the entire query can be replaced with:
SELECT ID FROM TT2