SQL: FETCH NEXT和 between and 的区别

 

--获取1000行数据,单位是行
SELECT ID FROM HIS_Message WHERE keyName IN ('S0035','S0036') ORDER BY ID OFFSET (1000 * (1 - 1)) ROW FETCH NEXT 1000 ROWS ONLY

效果图如下:SQL: FETCH NEXT和 between and 的区别_第1张图片

 

--获取ID为1-1000的数据,单位是ID值
SELECT ID FROM HIS_Message WHERE keyName IN ('S0035','S0036') AND ID BETWEEN 1 AND 1000 ORDER BY ID 

SQL: FETCH NEXT和 between and 的区别_第2张图片

备注:因为表的ID是不连续的

你可能感兴趣的:(SQL,SERVER)