Order by day_of_week in MySQL

后端 未结 10 2158
一向
一向 2020-12-14 04:15

How can I order the mysql result by varchar column that contains day of week name?

Note that MONDAY should goes first, not SUNDAY.

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 05:00

    I'm thinking that short of redesigning the column to use an enum instead, there's not a lot to be done for it, apart from sorting the results after you've gotten them out.

    Edit: A dirty hack is of course to add another table with id:weekday pairs and using joins or select in selects to fake an enum.

提交回复
热议问题