zoukankan      html  css  js  c++  java
  • 分页查询+万能---数据库例题的学生老师信息表为前提

    --至查询student表的第3、4行--分页查询 ★必须要用主键Sno来排除,防止重复
    select *from Student
    select top 2 *from Student where Sno not in(select top 2 Sno from Student)--第二页,屏蔽掉当前页的前面页的内容,前面top是取屏蔽之后的数据的一页显示条数
    --2行为一页
    select top 2 *from Student where Sno not in(select top 4 Sno from Student)--第三页
    create proc wannengfenye--只对一个列有主键的表的分页,符合主键的不能分
    @nowye int,--当前页
    @numbers int, --一显示行数
    @tablename varchar(50),--表名
    @zhujian varchar(50)
    as
    exec ('select top ('+@numbers+') *from '+@tablename+'  where '+@zhujian+' not in (select top (('+@nowye+'-1)*'+@numbers+') '+@zhujian+' from '+@tablename+' )')
    --直接写表名from不知别,先进行拼接字符串
    go
    exec wannengfenye 2,1,'student','sno'--然后执行自动把输入参数字符串转换成exce语句
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    2019-07-26
    2019-07-25
    免费的论文查重网站
    图片转链接
    hexo GitHub创建博客是遇到的问题
    苹果手机安装小火箭
    旅游--南京
    查看电脑基本信息以及电脑性能分析
    Android 不能root
    x-mind ZEN 指定安装路径(其他默认安装c盘可参考)
  • 原文地址:https://www.cnblogs.com/dlexia/p/4460640.html
Copyright © 2011-2022 走看看