Is it possible to order multiple columns by using the `ORDER BY FIELD` statement?

大兔子大兔子 提交于 2019-12-06 14:26:14

问题


I am using Ruby on Rails 3.2.2 and I would like to know if it is possible to order multiple columns/fields by using the ORDER BY FIELD statement (for example, as made in the Model.order("orders_count, created_at, name, ...") but for ORDER BY FIELD).

If so, how can I "ORDER BY FIELDS"?

P.S.: As written in a previous answer, in order to order my records relating to one column I am using the Model.order("field(status, 'blocked', 'unpublished', 'published')") statement.

来源:https://stackoverflow.com/questions/10646877/is-it-possible-to-order-multiple-columns-by-using-the-order-by-field-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!