Oracle中查询前10行记录:
select * from myTableName where rownum<10
SQLServer中查询前10行记录:
select top 10 * from myTableName
去重复:
#select distinct name,age from student;
#select * from student;
#select max(id),name,min(age),count(name) from student group by name;
#select distinct * from student;
select distinct name ,count(name) from student;
查询行:
#mysql 查询第几行到第几行记录的语句
#select * from student t limit 1;
#select * from table1 limit n-1,m-n;
#select * from student t limit 1,3;#2到4行
#select * from student t limit 3,1;#返回低4行
#select * from student t limit 0,3;#查询前n行
#select * from student t limit 3;#查询前n行
#select * from student t order by id desc limit 2;#查询后n行记录 //倒序排序,取前n行 id为自增形式
#查询一条记录($id)的下一条记录
#select * from table1 where id>$id order by id asc dlimit 1
#查询一条记录($id)的上一条记录
#select * from table1 where id<$id order by id desc dlimit 1
http://www.jb51.net/article/55063.htm
oracle:
select * from student t where rownum<=5 minus
select * from student t where rownum<=2;
mysql/SQL SERVER: 主键
select top 2 * from
(select top 5 * from student ) a
order by id desc
没主键:
select top 5 * from student
where id not in (
select top 2 id from student
)