LoginSignup
2
1

More than 5 years have passed since last update.

MySQLでソートしてn番目のカラムを取得する

Last updated at Posted at 2017-06-15

limit句とoffset句を使うと簡単にできる

以下の例は小さい方から2番めのデータを取得する例

SELECT
  column_name
FROM
  table_name
ORDER BY column_name
LIMIT 1
OFFSET 1

単純にOFFSET使って何番目のデータを取得するか指定しているだけ

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