Reputation: 8113
Given the following code:
SELECT YEAR(post_date) AS y, count(ID) as posts_count
FROM fdr_posts p
WHERE
p.post_status = 'publish'
OR p.post_status = 'future'
AND p.post_type = 'event'
GROUP BY y
ORDER BY post_date ASC
How can I exclude from column y certain years? So, every year except say, 2016 and 2017?
Upvotes: 0
Views: 39
Reputation: 1833
WHERE
p.post_status IN ( 'publish' , 'future' )
AND p.post_type = 'event'
AND YEAR(p.post_date) NOT IN (2016,2017)
Upvotes: 3