简体   繁体   English

如何从年份(列)结果中排除某些年份?

[英]How to exclude certain years from a year(column) result?

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? 如何从某些年份的y列中排除? So, every year except say, 2016 and 2017? 那么,每年除了说2016年和2017年?

WHERE 
p.post_status IN ( 'publish' , 'future' ) 
AND p.post_type = 'event'
AND YEAR(p.post_date) NOT IN (2016,2017)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM