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语句
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    AWS Dynamodb aggregation的处理问题
    Java线程池的实现与应用
    机器学习笔记之基本框架:
    Azure machine learning series 1 Introduction
    AWS的安全机制
    模板
    矩阵快速幂总结
    中位数总结
    KMP算法
    动态规划----背包总结
  • 原文地址:https://www.cnblogs.com/dlexia/p/4460640.html
Copyright © 2011-2022 走看看