🖥

MySQL — Error When Subquery Is Not AS | Every derived table must have

2019/04/16に公開

problem

For example, if you write a subquery like this, you get angry.

 SELECT * FROM ( SELECT User from user ); 

 => ERROR 1248 (42000): Every derived table must have its own alias 

Solution

Give some table name (alias name) in AS.

 SELECT * FROM ( SELECT User from user ) AS account; 

 +-----------+ | User | +-----------+ | mysql.sys | | root | +-----------+ 

the reason

If you do not write AS, SQL is interpreted syntactically like "FROM (without table name)".

environment

  • mysql Ver 14.14 Distrib 5.7.12, for osx 10.11 (x86_64) using EditLine wrapper

Original by

MySQL — サブクエリに AS を付けないとエラーを起こす | Every derived table must have its own alias

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion