在MySQL中,使用 field 函数可以自定义排序规则,使用方式如下:
select * from terminal order by field(state, 'online', 'offline', 'upgrading')