limit后面至少跟一个函数吧?

解决方案 »

  1.   

    limit 后面跟的必须是常量
      

  2.   

    limit 后面当然能用变量啦,只是提交到 MySQL 的时候,startIndex, endIndex 必须要有具体的数值,有就可以!
      

  3.   

    要设置startIndex和endIndex的值,INT默认值为0,就是一条记录都不返回了
      

  4.   

    DELIMITER $$DROP PROCEDURE IF EXISTS `isb_service`.`Select_Templates` $$
    CREATE PROCEDURE `isb_service`.`Select_Templates` (
      in in_startIndex integer,
      in in_maxPerPage integer
    )
    BEGIN
      Declare startIndex integer;
      Declare maxPerPage integer;  set startIndex=in_startIndex;
      set maxPerPage=in_maxPerPage;  select * from `templates` limit startIndex,maxPerPage;
    END $$DELIMITER ;
      

  5.   

    以上的代码无法通过,将startIndex,maxPerPage换成常量后又可以了
      

  6.   

    请问到底怎样才可以在limit后面使用变量?
      

  7.   

    兄弟,是MySQL自身的问题,它不支持limit使用变量!
    我觉得是MySQL存储过程编译器,不支持limit使用变量,
    可能是MySQL开发人员当时没想到limit使用变量吧
      

  8.   

    难道不能自己组装一条sql语句,非得在那里放上变量吗?
    C里面的组装方式:sprintf(buffer, "select * from `templates` limit %d, %d", startIndex, maxPerPage);