4
0

More than 5 years have passed since last update.

10以上の文字列のORDER BYは気をつけないとダメ

Posted at

数値でソートするカラムが数値型なら問題ないですが、
文字列型の場合のソートは挙動が変わります。

数値型の場合
1,2,3,4,5,6,7,8,9,10,11
文字列型の場合
1,10,11,2,3,4,5,6,7,8,9

原因としては文字列で見てしまうので最初の文字が「1」なので「1」「10」「11」が「2」より優先されてしまいます。

4
0
4

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
4
0