Can I get the position of a record in a SQL result table?

后端 未结 6 985
日久生厌
日久生厌 2020-12-16 02:35

If I do something like

SELECT * FROM mytable ORDER BY mycolumn ASC;

I get a result table in a specific order.

Is there a way in SQL

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 02:52

    SQL doesn't work that way. It's set-based, which means that "position in that result table" is meaningless to the database.

    You can keep track of position when you map the ResultSet into a collection of objects or when you iterate over it.

提交回复
热议问题