Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
首先,我想说明这不是一个简单的LIMIT x,y问题。我想知道是否可以进行类似以下 peuso 查询的查询。
LIMIT x,y
SELECT *, OFFSET_OF_ROW() FROM `table` WHERE `some_column` = someValue ORDER BY `some_other_column`;
OFFSET_OF_ROW()如果没有条件`some_column= someValue` ,伪函数应该给出所选行(+1)之前的行数
OFFSET_OF_ROW()
`some_column
这不是特别有效,但它会做你想要的:
select @rownum := 0; select * from ( select @rownum := @rownum + 1, id, some_column, sortcol from `table` order by `sortcol` ) all_rows where `some_column` = someValue;