List:General Discussion« Previous MessageNext Message »
From:Tompkins Neil Date:September 27 2010 9:49am
Subject:Re: Advanced query help
View as plain text  
Hi,

I did try defining it before the IF statement, but still the same ?

Cheers
Neil

On Mon, Sep 27, 2010 at 7:58 AM, Johan De Meersman <vegivamp@stripped>wrote:

> At a guess, because you use @team in an if statement before you actually
> define it.
>
>
> On Sun, Sep 26, 2010 at 12:35 AM, Tompkins Neil <
> neil.tompkins@stripped> wrote:
>
>> Hi,
>>
>> I've the following query
>>
>> SELECT teams_id AS teams_id ,SUM(rating) AS total_team_rating FROM (SELECT
>> teams_id ,players_id ,rating ,IF(@team <> teams_id, @row := 1, @row :=
>> @row
>> + 1) AS rank ,@team := teams_id FROM ( SELECT players.teams_id
>> ,players.players_id ,players_master.rating FROM players JOIN
>> players_master
>> ON players.players_id = players_master.players_id WHERE players.worlds_id
>> =
>> 1 AND players.red_cards = 0 AND players.injury_duration_remaining = 0 AND
>> players.teams_id > 0 ORDER BY players.teams_id, players_master.rating
>> DESC)
>> s1) s2 WHERE rank <= 11 GROUP BY teams_id ORDER BY total_team_rating DESC
>>
>> I'm running MySQL 5.0.77.  However, if I run this query nothing is
>> returned,
>> but if I run the query again I get the desired results.  Why is this ?
>>
>> Cheers
>> Neil
>>
>
>
>
> --
> Bier met grenadyn
> Is als mosterd by den wyn
> Sy die't drinkt, is eene kwezel
> Hy die't drinkt, is ras een ezel
>

Thread
Advanced query helpTompkins Neil26 Sep
  • Re: Advanced query helpJohan De Meersman27 Sep
    • Re: Advanced query helpTompkins Neil27 Sep
      • Re: Advanced query helpJohan De Meersman27 Sep