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.

【チートシート】 SQLのコマンド一覧(データの並び替え)

Last updated at Posted at 2022-03-22

指定したカラムの値を並び替えたデータを取得( ORDER BY )

db-sample
SELECT 表示カラム名①, 表示カラム名②, ... FROM DB.テーブル名 ORDER BY 指定カラム名① 並び替え条件①, 指定カラム名② 並び替え条件② ... ;

特定のデータを取得した後に指定したカラムの値を並び替えたデータを取得( WHERE + ORDER BY )

db-sample
SELECT 表示カラム名①, 表示カラム名②, ... FROM DB.テーブル名 WHERE 条件式 ORDER BY 指定カラム名① 並び替え条件①, 指定カラム名② 並び替え条件② ... ;

( ORDER BY )の記述方法

■昇順

db-sample
ORDER BY 指定カラム名 ASC

又は

db-sample
ORDER BY 指定カラム名

■降順

db-sample
ORDER BY 指定カラム名 DESC
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?