How to sort MySQL results with letters first, symbols last?

前端 未结 4 1740
盖世英雄少女心
盖世英雄少女心 2020-12-19 13:20

Long-time reader, first-time poster here.

I\'m trying to figure out how to sort a list of artists for a music app I\'m writing.

To help understand the databa

4条回答
  •  心在旅途
    2020-12-19 14:08

    You can add an extra ORDER BY clause that puts the items that start with a non-alphabetic character last, like so:

        SELECT artist
          FROM songs
      ORDER BY artist REGEXP '^[^A-Za-z]' ASC, artist
    

    This should move every artist that doesn't start with A-Z or a-z to the end of your ordering.

提交回复
热议问题