1
1

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 3 years have passed since last update.

SQLのCASE文

Last updated at Posted at 2020-05-04

SQL文のCASE演算子は、列の値や条件式を確認し、結果に応じて値を変化することができる。

####値の時

CASE 列の値 WHEN 値1 THEN 値1のときに返す値
       (WHEN 値2 THEN 値2のときに返す値)
       (ELSE それ以外)
END

####条件の時

CASE WHEN 条件1 THEN 条件1のときに返す値
   (WHEN 条件2 THEN 条件2のときに返す値)
   (ELSE それ以外)
END

式の結果に応じて複数のパターンの結果を得るために有用である。
(例、数値で管理しているカラムにて文字で表示させるときなど)

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?