数据库要点

来源:互联网 发布:电脑淘宝图片尺寸 编辑:程序博客网 时间:2024/05/01 16:12




--子查询:就是使用查询语句查询一列数据出来,然作为其他查询的查询条件参数来使用


--查询身高不在年龄是22岁的人的身高范围之内的信息



select * from xueshengxinxi where shengao not in (select shengao fromxueshengxinxi wherenianling =22)


select*from xueshengxinxi where shenfenzheng not in (178,161,162)


--名字叫Add的人中的年龄比no=5Ddd的那个人的年龄大3岁的人的信息



select*from xueshengxinxi where nianling-(selectnianling from xueshengxinxi where no =5)>3 and name='Add'


--查询表中前3人的信息top(前多少行)

select top 3 *from xueshengxinxi


selectdistinct name from xueshengxinxi


--查询不重名的人信息distinct(去重)


select*from xueshengxinxi order by tizhong asc


--依表中体重为条件进行升序排序(轻在前,重在后) asc (升序)


select*from xueshengxinxi order by tizhong desc


--依表中体重为条件进行降序排序(重在后,轻在前) desc(降序)


select*from xueshengxinxi order by nianling asc,shengaodesc


--先依表中年龄进行排序当遇到想的的年龄值时再以身高为条件对相等的值进行降序排序


selectname from xueshengxinxi group by name


--建立以name为条件的分组(只能显示一列并且只有一列,对那个列分组就只显示那一列)


select*from xueshengxinxi where nianling in (22,23)


select*from xueshengxinxi where nianling=22 ornianling=23


--二者意思一样但是表达方式不同都是选出表中年龄在到之间的人


select*from xueshengxinxi where nianling not in(22,23)


--排除表中与岁的人




0 0
原创粉丝点击