ORDER BY “ENUM field” in MYSQL

前端 未结 5 754
忘掉有多难
忘掉有多难 2020-12-04 23:40

There is a field \'noticeBy\' enum(\'email\',\'mobile\',\'all\',\'auto\',\'nothing\') NOT NULL DEFAULT \'auto\'. As it known ordering by ENUM field performs relative to its

5条回答
  •  感情败类
    2020-12-05 00:12

    The best option to me:

    ORDER BY FIELD(status, 'publish','not-publish','expirated','deleted'), creation DESC
    

    Status is the field in my BBDD, and values in '' are the values that has in enum options.

    I hope that help u too! :)

提交回复
热议问题