MySQL error: "Each derived table must have its own alias" What does it mean?
P粉218361972
P粉218361972 2023-10-10 20:45:21
0
2
758

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粉218361972
P粉218361972

reply all(2)
P粉545218185

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粉729436537

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template