时间:2021-07-01 10:21:17 帮助过:3人阅读
1. Oracle数据库
SELECT * FROM TABLENAME WHERE ROWNUM <= N
2. Infomix数据库
SELECT FIRST N * FROM TABLENAME
3. DB2数据库
SELECT *
FROM (SELECT * ROW_NUMBER() OVER({ORDER BY COL1 DESC}) AS ROWNUM FROM TABLENAME)
WHERE ROWNUM <= N
或者
SELECT COLUMN FROM TABLENAME FETCH FIRST N ROWS ONLY
4. SQL Server数据库
SELECT TOP N * FROM TABLENAME
5. Sybase数据库
SET ROWCOUNT N
GO
SELECT * FROM TABLENAME
6. MySQL数据库
SELECT * FROM TABLENAME LIMIT N
2 DB2
select column from [tableName] where [query condition] fetch first 10 rows only
3 MySQL
select * from [tableName] where [query condition] limit 10
4 SQL Server
4.1 读取前10条
select top (10) * from [tableName] where [query condition]
4.2 读取后10条
select top (10) * from [tableName] order by id desc
4.3 按照某个排序,第5到10这几个记录
select top 6 * from [tableName] where id not in(select top 4 id from [tableName])
5 Oracle
select * from [tableName] where rownum<=10
Oracle查询第10行到第100行的数据
select * from (select t.*,rownum as rn from table_name t) where rn between 10 and 100;
1、Oracle查找表中字段的值是否为空?
select * from table_name where 字段名 is (not) null;
2、查找表中字段是否是某个值
select * from table_name where 字段名=‘字段值‘;
3、更改表中字段原来的值为新的值
update table_name SET 字段名=‘新的字段值’ where 字段名=‘旧的字段值’
各数据库查询前N行的数据SQL
标签:set 记录 字段 blog query pos row mysq ble