zoukankan      html  css  js  c++  java
  • 今儿改的

    select title from Bao_ZhaoShang where Title like '%胶囊%'


    SELECT TOP 10 bu.Companyname,bu.QQ,bz.ID,bz.UserID,bz.Title,bz.Types,bz.propic,bz.Province,bz.addtime,bz.biaozhun,bz.Hits
    from Bao_Zhaoshang bz,Bao_User bu
    where bz.UserID = bu.UserID and bz.IsShenHe = 1 and bz.title like '%胶囊%' and bz.id<(SELECT min(id) FROM (SELECT TOP 10 bz.id  FROM Bao_Zhaoshang bz  where bz.IsShenHe = 1 and bz.title like '%胶囊%' order by Addtime desc) AS TabTemp)
    order by Addtime desc


    EXEC GetDataPager 'Bao_Zhaoshang bz','bz.ID,bz.UserID','AddTime',10,2,1,1,'Title like ''%胶囊%'' and IsShenHe = 1 '

    EXEC getUserbyID 16

    CREATE PROCEDURE getUserbyID
    @UserID int
    as
    declare @strSQL nvarchar(4000) -- 主语句
    begin
         set @strSQL = 'Select UserID,QQ,CompanyName from Bao_User where UserID ='+ str(@UserID)
    end

    exec (@strSQL)
    go

    CREATE PROCEDURE GetDataPager
    @tblName varchar(255), -- 表名
    @strGetFields varchar(1000) = '*', -- 需要返回的列
    @fldName varchar(255)='', -- 排序的字段名
    @PageSize int = 10, -- 页尺寸
    @PageIndex int = 1, -- 页码
    @doCount bit = 0, -- 返回记录总数, 非 0 值则返回
    @OrderType bit = 0, -- 设置排序类型, 非 0 值则降序
    @strWhere nvarchar(1000) = '' -- 查询条件 (注意: 不要加 where)
    AS

    declare @strSQL nvarchar(4000) -- 主语句
    declare @strTmp varchar(110) -- 临时变量
    declare @strOrder varchar(400) -- 排序类型

    if @doCount != 0 --如果@doCount传递过来的不是0,就执行总数统计
    begin
    if @strWhere !=''
    set @strSQL = 'SELECT COUNT(*) AS Total FROM ' + @tblName + ' WHERE ' + @strWhere
    else
    set @strSQL = 'SELECT COUNT(*) AS Total FROM ' + @tblName
    end

    else

    begin

    if @OrderType != 0

    begin
    set @strTmp = '<(SELECT MIN'
    set @strOrder = ' ORDER BY ' + @fldName +' DESC'

    --如果@OrderType不是0,就执行降序
    end

    else

    begin

    set @strTmp = '>(SELECT MAX'
    set @strOrder = ' ORDER BY ' + @fldName +' ASC'

    end

    if @PageIndex = 1

    begin

    if @strWhere != ''
    set @strSQL = 'SELECT TOP ' + str(@PageSize) +' '+@strGetFields+ ' FROM ' + @tblName + ' WHERE ' + @strWhere + ' ' + @strOrder
    else
    set @strSQL = 'SELECT TOP ' + str(@PageSize) +' '+@strGetFields+ ' FROM '+ @tblName + ' '+ @strOrder

    --如果是第一页就执行以上代码,这样会加快执行速度
    end

    else

    begin

    --以下代码赋予了@strSQL以真正执行的SQL代码

    set @strSQL = 'SELECT TOP ' + str(@PageSize) +' '+@strGetFields+ ' FROM '
    + @tblName + ' WHERE ' + @fldName + '' + @strTmp + '('+ @fldName + ') FROM (SELECT TOP ' + str((@PageIndex-1)*@PageSize) + ' '+ @fldName + ' FROM ' + @tblName + '' + @strOrder + ') AS tblTmp)'+ @strOrder

    if @strWhere != ''
    set @strSQL = 'SELECT TOP ' + str(@PageSize) +' '+@strGetFields+ ' FROM '
    + @tblName + ' WHERE ' + @fldName + '' + @strTmp + '('
    + @fldName + ') FROM (SELECT TOP ' + str((@PageIndex-1)*@PageSize) + ' '
    + @fldName + ' FROM ' + @tblName + ' WHERE ' + @strWhere + ' '
    + @strOrder + ') AS tblTmp) AND ' + @strWhere + ' ' + @strOrder
    end

    end

    exec (@strSQL)
    GO

  • 相关阅读:
    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 问题解决方法
    springboot入门(一)--快速搭建一个springboot框架
    SpringBoot 中常用注解@Controller/@RestController/@RequestMapping介绍
    理解Spring4.0新特性@RestController注解
    Intellij IDEA 搭建Spring Boot项目(一)
    Java checked 异常 和 RuntimeException(运行时异常)
    Java 如何抛出异常、自定义异常、手动或主动抛出异常
    微服务设计
    为什么需要API网关?
    微服务API网关
  • 原文地址:https://www.cnblogs.com/pipizhu/p/1623934.html
Copyright © 2011-2022 走看看