我想选择在特定uuid之后开始的所有行,例如这里是数据
+--------------------------------------+-----------+------------+
| uuid | divisi_id | divisionid |
+--------------------------------------+-----------+------------+
| b303a96b-2a03-4b5e-90a1-6b3631fc82af | BTT | 3 |
| 8c4bf1b8-7477-42e4-affb-31bafa8648f1 | BTT | 3 |
| 6639909d-74e1-4dec-a1f3-f70703c0b6c6 | BTT | 3 |
| 1a1aa367-1467-4811-848d-694dbe98a5a8 | BTT | 3 |
| e739b352-d952-4ec8-980e-a50180e18144 | BTT | 3 |
+--------------------------------------+-----------+------------+
现在,例如我有uuid
= 8c4bf1b8-7477-42e4-affb-31bafa8648f1
(第2个条目)。如何在那个uuid之后选择行?我根本不知道。
答案 0 :(得分:0)
试试这个
SELECT d1.* FROM
(SELECT Row_Number() over (order by id) AS RowIndex, * from tableName ) AS d1
INNER JOIN
(SELECT Row_Number() over (order by id) AS RowIndex, * from tableName) AS d2
ON (d2.uuid = '8c4bf1b8-7477-42e4-affb-31bafa8648f1' and d1.RowIndex > d2.RowIndex)
希望你有主键!!
如果您没有主键而不是
SELECT d1.* FROM
(SELECT Row_Number() over (order by (select null)) AS RowIndex, * from tableName) AS d1
INNER JOIN
(SELECT Row_Number() over (order by (select null)) AS RowIndex, * from tableName) AS d2
ON (d2.uuid = '8c4bf1b8-7477-42e4-affb-31bafa8648f1' and d1.RowIndex > d2.RowIndex)