List:General Discussion« Previous MessageNext Message »
From:Tompkins Neil Date:October 19 2010 3:50pm
Subject:Fwd: If within If ?
View as plain text  
Hi,

I think I've managed to do it :

SELECT
IF(competitions.competition_type = 'cup',
IFNULL(ROUND(SUM(gate_receipts)/2),0), IFNULL(SUM(gate_receipts),0))AS
gate_receipts
FROM fixtures_results
INNER JOIN competitions ON fixtures_results.competitions_id =
competitions.competitions_id
WHERE home_teams_id = 27
AND worlds_id = 1 AND status = 'approved'

Cheers
Neil


---------- Forwarded message ----------
From: Tompkins Neil <neil.tompkins@stripped>
Date: Tue, Oct 19, 2010 at 2:01 PM
Subject: If within If ?
To: "[MySQL]" <mysql@stripped>


Hi,

I've the following query :

SELECT IFNULL(SUM(gate_receipts),0) AS gate_receipts, competitions.caption
FROM fixtures_results
INNER JOIN competitions ON fixtures_results.competitions_id =
competitions.competitions_id
WHERE home_teams_id = 27
AND worlds_id = 1 AND status = 'approved'

However, I want to check the value of competitions.competition_type and if
it is 'cup' I want to divide the value of gate_receipts by 2.  How is the
best way to achieve this ?

Regards
Neil

Thread
If within If ?Tompkins Neil19 Oct
  • Fwd: If within If ?Tompkins Neil19 Oct