Selecting Nth Record in an SQL Query

后端 未结 12 1051
悲&欢浪女
悲&欢浪女 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条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 23:58

    From the SELECT reference, use the LIMIT keyword:

    SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
    SELECT * FROM tbl LIMIT 5;     # Retrieve first 5 rows
    

    Note: this is for MySQL, other SQL engines may have a different keyword.

提交回复
热议问题