sql

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
)

 

转载于:https://www.cnblogs.com/zshboke-2015/p/5508894.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值