Natural Sorting in MySQL

Working Around MySQL's Lack of Built-In Support for Natural Sorting

Several times in the last few projects I've built, I've come across the need to sort alphanumeric rows in a database by number (i.e. entry1, entry2, entry3, etc.). If you've ever tried to do this, you know that sorting entries that are alphanumeric is a pain.

The Data

For our purposes, we'll be using the following table:

Table: sorting_test +--------------------------+-------------+ | alphanumeric VARCHAR(75) | integer INT | +--------------------------+-------------+ | test1 | 1 | | test2 | 2 ... read more

  • «
  • 1
  • »