Selecting Nth Record in an SQL Query

后端 未结 12 959
悲&欢浪女
悲&欢浪女 2020-12-28 23:33

I have an SQL Query that i\'m running but I only want to select a specific row. For example lets say my query was:

Select * from Comments

L

12条回答
  •  -上瘾入骨i
    2020-12-29 00:01

    I have read the question & your comments on you would want next 3 blog comments etc.

    How is your tables structured?
    Assume that you have blog post Id & comment Id is generated in ascending order for each blog post, you could do a SELECT based on the current Id.

    e.g. if the blogpostId = 101, you get the top 3 comments order by posted Id. Now lets say, you want to get the next 3 comments - you could do a SELECT WHERE commentId between the last comment id shown TO the comment id - 3

    But all that depends on how your tables are defined.

提交回复
热议问题