Haha, yes I know that. I just created the code in the email editor. :)

-----Original Message-----
From: Barry [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 10, 2006 5:19 PM
To: mysql@lists.mysql.com
Subject: Re: Do if and elseif and other calculations

Peter Lauri wrote:
> Best groupmember,
> 
> I have this query
> 
> SELECT count(*) AS number_of_holes, tour_player_score.strokes -
> tour_scorecard_hole.par AS overpar
> FROM `tour_player_score`, tour_scorecard_hole WHERE tour_player_id=175 AND
> tour_scorecard_hole.id=tour_player_score.scorecard_hole_id GROUP BY
overpar
> 
> It gives me number_of_holes and overpar.
> 
> Right now I do this with PHP, but would like to move it to sql directly:
> 
> $diff = 0;
> While($Row = mysql_fetch_array()) {
>       If($Row['overpar'])<0) $diff = $diff - $Row['overpar']*
> $Row['number_of_holes'];
>       Elseif($Row['overpar']>=3) diff = $diff - $Row['overpar']*
----------------------------------^
You have an error here.
You miss a ´$´
> $Row['number_of_holes'] + 2;
> }
> 
> Anyway to move this to MySQL and just have one row containing the diff?
Sorry can't give any more comments to that.

Looking forward to see the comments on this.

Greets
        Barry
-- 
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to