0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Last updated at Posted at 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オープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?