Reputation: 10192
How can I exclude rows with show_all = '1'
from HAVING clause?
SELECT
ID,
( 6371 * acos( cos( radians('". $lat ."') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('". $long ."') ) + sin( radians('". $lat ."') ) * sin( radians( lat ) ) ) ) AS distance
FROM events
WHERE active = '1'
AND closed = '0'
AND category IN ( '" . implode( "', '" , $styleArr ) . "' )
HAVING distance < 1000 AND distance > 0
ORDER BY events.start_date DESC
I don't want to apply HAVING condition if row's show_all = '1'
Upvotes: 0
Views: 30
Reputation: 164204
Change the HAVING clause to this:
HAVING (distance < 1000 AND distance > 0) OR show_all = '1'
Upvotes: 1