The following article introduces the mysql database SQL statements and the actual steps for getting n-m pieces of data in the table, at the same time, it also includes some other common database SQL statements to take n-m pieces of data from the relevant table. We first write the content we want to express in the way of proposition.
Proposition: Write an SQL statement: take out the ID Automatically increasing from 31st to 40th records in Table A as the primary key. Note: The ID may not be consecutive .)
Oracle Database:
- select * from A where rownum<=40 minus select * from A where rownum<=30
SQL Server database:
- select top 10 * from A where id not in (select top 30 id from A )
- select top 10 * from A where id>(select max(id) from (select top 30 id A) as A)
Mysql database:
- SELECT * FROM A LIMIT 30,40
The above content is an introduction to the SQL statements of the mysql database. I hope you will find some gains.