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

时间:2017-09-21 16:32:40

标签: mysql sql date

给出以下代码:

<div class="productwrap">
  <div class="productbox">
    <img class="brand" alt="brand" src="http://via.placeholder.com/190x120.png">
  </div>
  <div class="productbox">
    <div class="minmaxtitle">
      <p>Detail</p>
    </div>
    <div class="minmax">
      <div class="min">From
        <br>1</div>
      <div class="max">To
        <br>2</div>
    </div>
  </div>
  <div class="productbox">
    <div class="minmaxtitle">
      <p>Detail</p>
    </div>
    <div class="minmax">
      <div class="min">From
        <br>1</div>
      <div class="max">To
        <br>2</div>
    </div>
  </div>
  <div class="productbox">
    <div class="minmaxtitle">
      <p>Detail</p>
    </div>
    <div class="minmax">
      <div class="min">From
        <br>1</div>
      <div class="max">To
        <br>2</div>
    </div>
  </div>
  <div class="productbox">
    <a class="apply" target="_blank" href="https://www.example.com">Link</a>
  </div>
</div>

如何从列y中排除某些年份?那么,除了2016年和2017年之外,每年都会这样做?

1 个答案:

答案 0 :(得分:3)

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