Selecting count(*) while checking for a value in the results

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2012-12-11T22:57:01Z Indexed on 2012/12/11 23:03 UTC
Read the original article Hit count: 101

Filed under:
|
SELECT COUNT(*) as Count, IF(sch.HomeTeamID = 34,true,false) AS Hawaii
FROM schedule sch 
JOIN schools s ON s.ID = 83 
WHERE (sch.HomeTeamID = 83 OR sch.AwayTeamID = 83)
AND sch.SeasonID = 4

I'm trying to use count() to simplify my result but also include a field that represents wether any of the results' specific column contained a certain value. Is this possible? I'd basically like a row response with all the info I need.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql