views:

26

answers:

2
SELECT
    challenger_name as name,
    IF(challenger_timeout > challenged_timeout,
        (SET  wins + 1),
        NULL) as wins,
    IF(challenger_timeout < challenged_timeout,
        (SET  lose + 1),
        NULL) as lose,
    IF(challenger_timeout = challenged_timeout,
        (SET  draw + 1),
        NULL) as draw
FROM time_trial_challenge
GROUP by challenger_name ORDER by wins DESC";

How to fix this query?

I hope you know what I am trying to do from this query. it is difficult for me to describe them into sentences

+2  A: 

SQL cannot do an UPDATE and a SELECT in the same query. Break it into two separate queries.

Ignacio Vazquez-Abrams
I suspect the `SET` wasn't meant to be an update, but a totaller / `SUM` for the column.
Wrikken
+3  A: 
SUM(IF(challenger_timeout > challenged_timeout,1,0)) as wins

... and do the same with your other IFs

oezi
SUM(challenger_timeout > challenged_timeout) as wins does the same thing
Naktibalda
SUM(challenger_timeout > challenged_timeout) i tried this but it gives me the numbers of all rows including the row with challenger_timeout < challenged_timeout for wins
bn
@bn : please post your revised query
ceteras
it works well! thank you
bn