开发者

How to get the next record in a MySQL table with multiple sort values

开发者 https://www.devze.com 2023-03-27 13:47 出处:网络
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 stateme

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消