难倒:phpMyAdmin,浏览器和查询浏览器返回相同查询的不同结果

时间:2012-05-09 07:06:33

标签: mysql sql

我正在尝试在网页上运行此查询:

 select 
   min(date) as start_date,
   max(date) as end_date,
   count(date) as streak,
   group_concat(gameid) as gameid_list
from
( 
  select *,      
    IF(
        pointsfor > pointsagainst 
        and 
        @pointsfor > @pointsagainst, 
           @gn, @gn := @gn + 1)                
    as group_number,

    @date as old_date, @gameid as old_gameid, 
    @pointsfor as old_pointsfor,
    @pointsagainst as old_pointsagainst,

    @date := date, @gameid := gameid, 
    @pointsfor := pointsfor, @pointsagainst := pointsagainst      
  from tbl
  cross join 
  (
    select 
      @date := CAST(null as date) as xa,
      @gameid := null + 0 as xb, 
      @pointsfor := null + 0 as xc, @pointsagainst := null + 0 as xd, @gn := 0
  ) x
  order by date
) as y
group by group_number
order by streak desc

查询所选择的表'tbl'看起来与此类似(尽管以下数据适用于不同的团队):

    date     gameid     pointsfor     pointsagainst

2011-03-20   15         1             10
2011-03-27   17         7             3
2011-04-03   23         6             5
2011-04-10   30         5             4
2011-04-17   35         4             8
2011-05-01   38         8             1
2011-05-08   43         3             7
2011-05-15   48         6             2
2011-05-22   56         10            2
2011-05-29   59         4             5
2011-06-05   65         2             3
2011-06-19   71         5             6
2011-06-19   74         12            2
2011-06-19   77         5             2
2011-06-19   80         5             4

当我在查询浏览器中运行查询时,结果数据与我在网页或phpmyadmin上运行查询时的数据不同。

如果我将查询回显到我的网页上,然后将其粘贴到我的查询浏览器中,我就会得到正确的结果。

另外,由于某种原因,当我在phpmyadmin中发布两次查询时,它会返回正确的结果。

我不知道为什么会这样!

0 个答案:

没有答案