title: Mysql get all records not processed previous month in current month
body: <p>I have a table which contains following records</p>
  
  <pre><code>slno | FirstName | LastName | Attended | Month  | Year |
  -----|-----------|----------|----------|--------|------|
  1    |  John     |  Smith   |   0      |   04   | 2017 |
  2    |  Jack     |  Paul    |   1      |   04   | 2017 |
  3    |  Jerry    |   Tom    |   1      |   04   | 2017 |
  4    |  Beth     |  Home    |   0      |   04   | 2017 |
  5    |  Julia    |  John    |   1      |   04   | 2017 |
  6    |  Cris     |  joy     |   0      |   05   | 2017 |
  7    |  Meiy     |  Rony    |   1      |   05   | 2017 |
  8    |  Ronald   |   Jony   |   1      |   05   | 2017 |
  9    |  Quest    |  Pio     |   0      |   05   | 2017 |
  10   |  Mary     |  June    |   1      |   05   | 2017 |
  11   |  Joy      |  Meth    |   0      |   03   | 2017 |
  12   |  Ruby     |  Rony    |   1      |   03   | 2017 |
  13   |  Royal    |   Jony   |   1      |   03   | 2017 |
  14   |  Tweet    |  Pio     |   0      |   03   | 2017 |
  15   |  Min      |  June    |   1      |   03   | 2017 |
  </code></pre>
  
  <p>I want to show the data based on month and year. 
  Eg: 04 2017  should show only April month data and March which is having attended=0. But when i search for 05 2017 , it should show May month data including previous months data which is Attended=0 [march and april].</p>
  
  <p>I have following statement:</p>
  
  <pre><code>select FirstName,LastName,Attended from UserTable 
  where Attended in (0,1)
  and ( Attended not in (1) or (Month='04' and Year='2017'));
  </code></pre>
  
  <p>I will get records what i want. But if i search for Month='03' Year='2017' , it shows all Attended=0 from May as well as from April. </p>
  
  <pre><code>if   Month='05' year='2017' -- current month
  
      6    |  Cris     |  joy     |   0      |   05   | 2017 |
      7    |  Meiy     |  Rony    |   1      |   05   | 2017 |
      8    |  Ronald   |   Jony   |   1      |   05   | 2017 |
      9    |  Quest    |  Pio     |   0      |   05   | 2017 |
      10   |  Mary     |  June    |   1      |   05   | 2017 |
      1    |  John     |  Smith   |   0      |   04   | 2017 |
      4    |  Beth     |  Home    |   0      |   04   | 2017 |
      11   |  Joy      |  Meth    |   0      |   03   | 2017 |
      14   |  Tweet    |  Pio     |   0      |   03   | 2017 |
  </code></pre>
  
  <p>if month='04' year='2017'</p>
  
  <pre><code>1    |  John     |  Smith   |   0      |   04   | 2017 |
  2    |  Jack     |  Paul    |   1      |   04   | 2017 |
  3    |  Jerry    |   Tom    |   1      |   04   | 2017 |
  4    |  Beth     |  Home    |   0      |   04   | 2017 |
  5    |  Julia    |  John    |   1      |   04   | 2017 |
  11   |  Joy      |  Meth    |   0      |   03   | 2017 |
  14   |  Tweet    |  Pio     |   0      |   03   | 2017 |
  </code></pre>
  
  <p>if month='03' year='2017'</p>
  
  <pre><code>11   |  Joy      |  Meth    |   0      |   03   | 2017 |
  12   |  Ruby     |  Rony    |   1      |   03   | 2017 |
  13   |  Royal    |   Jony   |   1      |   03   | 2017 |
  14   |  Tweet    |  Pio     |   0      |   03   | 2017 |
  15   |  Min      |  June    |   1      |   03   | 2017 |
  </code></pre>
  
  <p>How can i do this ?</p>