分组通过在每次刷新时给出不同的结果(行chages的顺序)?

时间:2016-01-30 07:05:30

标签: mysql

我已经使用group进行了动态查询,当我刷新页面时,我得到了不同的结果。查询如下。

  CREATE DEFINER=`root`@`%` PROCEDURE `proc_productlisting26jan`(IN `storeamount` INT, IN `getcatid` INT, IN `pid` INT, IN `per_page` INT)
    LANGUAGE SQL
    NOT DETERMINISTIC
    CONTAINS SQL
    SQL SECURITY DEFINER
    COMMENT ''
begin
    set @storeamount = storeamount;
    set @getcatid    = getcatid;
    set @query2 = concat('select prodtmappid,totalrating,SKUNO,ProId,CatId,fn_proQuantiry(prodtmappid) as proQnty,
    productMRP,ProDisPrice,SellingPrice,AdditionDiscount,Round(FinalPrice) as FinalPrice,Round(ProDiscount) as ProDiscount,ProDisType,ProductName as ProName,TotalValues,
image,BrandId,FDisId,ColorID,SizeID  from tblproductmapforlisting ',

     case when @storeamount = 0 then ' where FinalPrice < 499 '  else '' end,
     case when @storeamount = 1 then ' where FinalPrice between 599 and 799 ' else '' end ,
     case when @storeamount = 2 then ' where FinalPrice between 800 and 999 ' else '' end,
     case when @getcatid    = 0 then ' and catId not in (486, 205, 204, 205, 207, 208, 209, 921, 924, 940, 147054, 203) ' else '  ' end, 
     case when @getcatid   =  4 then ' and catId in(255,259,307,310,331,333,334,336,410,414,417,434,878,931,108,627,641,647,650,656,658,660,875,876,896,897)' else ' ' end, 
     case when @getcatid   =  1 then ' and catId in (3,7,9,804,872,956,1101,788,758,459,489,492,493,494,495,633,806,917,964,1113,938,939,923,541,544,548,541,565,654,673)' else ' ' end, 
     case when @getcatid   =  2 then ' and catId in (35,36,37,38,39,40,41,42,252,253,912,1108,1109,1110,46,47,48,49,51,52,54,56,786,881,246,248,250,791,819,941,952,247,612,792,793,60,64,99,103,110,112,122,126)' else ' ' end, 
     case when @getcatid   = 3 then ' and catId in (80,810,820,946,1042,1112,1178,1179,193,199,201,839,869,935,1071,225,226,71,97,100,101,102,114,802,930,1086,1089,78,154,156,157,158,159,160,161,162,164,795,796,797,1037,212,168,169,171,172,174,175,824,825,181,182,183,184,185,187,188,801,910,1072)' else ' ' end, 
     case when @getcatid  = 5 then ' and catId in (294,296,301,305,311,809,393,916,317,318,321,322,323,324,326,1007,441,423,428,1065,1181,337,339,358,1183,376,386)' else ' ' end, 
     case when @getcatid   = 6 then ' and catId in (444,445,446,448,449,451,453,455,458,460,461,807,960,1010,1013,1036,572,573,574,575,576,582,586,590,593,763,766,844,847) ' else ' ' end, 
     case when @getcatid  = 7 then ' and catId in (232,233,235,239,834,909,913,933,980,1084,1012,1033,1034,992,993,994,995,996,997,999,1001,1024,1025,1026,1027,1039)' else ' ' end ,  
     ' and proQnty>0 and ProStatus = "A"  group by Proid  order by  tblproductmapforlisting.getrand desc ',
     ' limit ',pid,',',per_page);
     -- group by Proid
     --  order by  tblproductmapforlisting.getrand desc
  --  select @query2;
   PREPARE stmt1 FROM @query2;
       EXECUTE stmt1;
  DEALLOCATE PREPARE stmt1;
end.

谢谢你帮助我我也在分享链接,看看实例,只是刷新页面有什么问题。 link

0 个答案:

没有答案