How do I write LINQ's .Skip(1000).Take(100) in pure SQL?

前端 未结 6 873
梦谈多话
梦谈多话 2020-11-29 18:45

What is the SQL equivalent of the .Skip() method in LINQ?

For example: I would like to select rows 1000-1100 from a specific database table.

Is

6条回答
  •  天命终不由人
    2020-11-29 19:14

    Try this one:

    select * from [Table-Name] order by [Column-Name] 
    offset [Skip-Count] rows
    FETCH NEXT [Take-Count] rows only
    

    Example:

    select * from Personals order by Id
    offset 10 rows            --------->Skip 10
    FETCH NEXT 15 rows only   --------->Take 15
    

提交回复
热议问题