How to get the next record in a MySQL table with multiple sort values
Suppose I had a table with 5 fields or so and I wanted the next record but I want it to be the next one as if the records were ordered by 3 of the fields, as seen 开发者_运维知识库in the MySQL statement below:
SELECT id FROM t1 ORDERBY f1 ASC, f2 ASC, f3 ASC;
Is there a way to do this?
Found a solution: By using Concat_ws of the two fields in both the WHERE (to select the next one) and the ORDER BY Clauses.
精彩评论