首页 > 数据库技术 > 详细

数据库(子查询、主键、外键)

时间:2014-11-05 22:44:03      阅读:303      评论:0      收藏:0      [点我收藏+]

-------子查询------------
select bumen,COUNT(*)as 人数 from haha group by bumen having COUNT(*)>=5
select MAX(nianling) from haha where bumen=‘销售部‘
select *from haha where bumen=‘销售部‘and nianling=56
--汇总
select *from haha where nianling = (
select MAX(nianling) from haha where bumen in(
select bumen from haha group by bumen having COUNT(*)>=5
)
)
and bumen =(select bumen from haha group by bumen having COUNT(*)>=5)

--查找男同志里面年龄最大的全部信息--
select MAX(xingming) from haha where xingbie =‘男‘
select *from haha where xingming =(select MAX(xingming) from haha where xingbie =‘男‘)

---分页代码---,

select top 5*from haha
select top 5*from haha where code not in(select top 5 code from haha)

--分页代码,前面top代表一页有多少条数据,后面代码是过滤当前页的前面页面的数据

--查看一个表最多能分成多少页
select ceiling(COUNT(*)/5.0)from haha

 

设置主键语句

 

bubuko.com,布布扣

bubuko.com,布布扣

 

bubuko.com,布布扣

关系-添加-表和列规范后面的省略号

bubuko.com,布布扣

 

bubuko.com,布布扣

点击确认后完成。

 

数据库(子查询、主键、外键)

原文:http://www.cnblogs.com/LCL390/p/4077416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!