您的位置:首页 > 博客中心 > 数据库 >

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

时间:2022-03-14 02:02

-------子查询------------
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

 

设置主键语句

 

gxlsystem.com,布布扣

gxlsystem.com,布布扣

 

gxlsystem.com,布布扣

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

gxlsystem.com,布布扣

 

gxlsystem.com,布布扣

点击确认后完成。

 

热门排行

今日推荐

热门手游