zoukankan      html  css  js  c++  java
  • 视图

    --视图:视图就是一个虚拟的表
    select *from view_1
    
    --显示所有学生的sno、sname、cno、degree
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno 
    --显示101学生的sno、sname、cno、degree
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno where Student.Sno=101
    
    create view view_2
    as
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno 
    go
    --视图,相当于起了一个别名 用于简便方法
    select*from view_2 where sno=101
    
    --子查询,将子查询查询出的结果集当做虚拟的临时表来使用
    select *from(select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno )as table2 where sno=101
    
    --分页查询
    --显示第三行第四行  ,后面not in屏蔽掉当前页的内容,前面top是取屏蔽之后的数据的一页显示条数,必须要用主键作为排除条件
    select top 2*from student where sno not in(select top 2 sno from student ) 
    
    --分页的存储过程
    create proc fenye
    @nowye int,--当前页
    @numbers int  --显示行数
    as
    --屏蔽数据,假设@nowye=1,@numbers=4 ,也就是说每1页有4条数据, 括号里面的是屏蔽的数据,若@nowye=1,@numbers=4,会屏蔽0条,也就是说会显示第一页的全部4条数据,以此类推
    select
    top (@numbers) *from student where sno not in(select top ((@nowye-1)*@numbers) sno from student ) go exec fenye 2,2 --创建万能分页 (未完善) create proc wannengfenye @nowye int,--当前页 @numbers int, --显示行数 @tablename varchar(50), @zhujian varchar(50) as select top (@numbers) *from @tablename where @zhujian not in(select top ((@nowye-1)*@numbers) @zhujian from @tablename) go exec fenye 2,2
  • 相关阅读:
    Day 10 网络基础
    Day9 编码和网络基础 Encoding and network
    Day 8 数据与进制转换
    Day 7 文件管理补充和练习 File management & exercises
    5--kubernetes实战初入门
    4--k8s之资源管理 ; yaml语言
    3--二进制安装k8s
    kubernetes之安装集群图形化界面Dadhboard
    2--kubeadm安装k8s
    1--kubernetes简介及架构图
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4461287.html
Copyright © 2011-2022 走看看