LoginSignup
10
6

More than 5 years have passed since last update.

MySQL FROM DUAL

Posted at

MySQL では下記のようなクエリが通る。

SELECT 1 as value;
-- value: 1 が返される

でも where 句をそのままつなげるとエラーになる。

SELECT 1 as value WHERE true;
-- You have an error in your SQL syntax; ~~ near 'WHERE true'

でも FROM DUAL を使えば where 句を書くことができる。

SELECT 1 as value FROM DUAL WHERE true;
-- value: 1 が返される

何に使うのだろうか。それは皆さんで考えて欲しい。

※私は仕事で偶然にも役にたった

10
6
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
10
6