@[TOC]

Case lead data

Browse record table: browse ID (autoincrement), browse user name, browse book name
drop table browserecord;
create table browserecord(
recordid int identity(1.1) not null primary key,
username varchar(255) not null,
bookname varchar(255) not null.)insert into browserecord values('little red'.'C++ programming ');
insert into browserecord values('little blue'.'C++ programming ');
insert into browserecord values('little red'.'C++ programming ');
insert into browserecord values('1'.'C++ programming ');
insert into browserecord values('1'.'Network Security'); . Add some more yourselfselect * from browserecord;
Copy the code

Case 1: check the first few

Mysql > select * from sqlserver where user name = 1 and user name = 1 and user name = 1

So write SQL

select TOP 5 *from browserecord where username = '1';
Copy the code

Case two: check a few to a few

What if you’re looking for information from four to seven

So let’s write SQL like this

SELECT TOP 4 * FROM browserecord 
WHERE browserecord.recordid
NOT IN
(SELECT TOP 3 recordid FROM browserecord)
Copy the code

If you want to look up data between n and M, the number in line 4 is n-1, and the number in line 1 is m-n+1, so that you can paging