0

I have table like

+-----------+------------+------+------+------+
| id        | name       | col1 |col2  | col3 |
+-----------+------------+------+------+------+

I want order my table with two column like (col1, col2) in (v1,v1),(v2,v2)... and some other order.

In MySQL has ORDER BY FIELD(col1, 'v1', 'v2', 'v3') DESC, other columns ASC; but how using it in multi column like my example thanks.

1 Answer 1

1

You can concatenate the strings.

ORDER BY FIELD(CONCAT(col1, ',', col2), 'v1,v1', 'v2,v2', ...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.