title: MySQL query returning no rows
body: <p>I have two MySQL tables. What I am trying to do is to export the information where Value 1 is 1 less than Value 2 AND where ID_1 does not have its Value 1 and Value 2 equal. </p>
  
  <p>Note:</p>
  
  <ul>
  <li>Fields Value 1 and 2 are just integers.</li>
  <li>Each distinct ID_A has the same Value_2</li>
  <li>If there are two Value_1s that are one less than Value_2, look to Value_3 and select one that is higher</li>
  <li>The reason why I have two tables here is because I am going to output information from both tables</li>
  <li>We can write a script for this, but I need to do this in a single command for bonus points (which my instructor declared is possible)... I haven't even started a script for this, as I don't really know how to do that...</li>
  </ul>
  
  <p><code>tableA</code> looks like this:</p>
  
  <pre><code>ID_1  ID_2
  A     A
  A     B
  B     A
  B     B
  C     A
  C     B
  C     C
  </code></pre>
  
  <p><code>tableB</code> looks like this:</p>
  
  <pre><code>ID_1  ID_2  Value_1  Value_2  Value_3
  A     A     2        3        NULL
  A     B     3        3        NULL
  B     A     4        5        NULL
  B     B     7        5        NULL
  C     A     7        8        98
  C     B     3        8        NULL
  C     C     7        8        56
  </code></pre>
  
  <p>The query should return this:</p>
  
  <pre><code>ID_1  ID_2
  B     A
  C     A
  </code></pre>
  
  <p>Here is what I have so far... And it keeps returning no hits, which is making me confused. I believe it is the AND clause after the first WHERE statement where I need to fix</p>
  
  <pre><code>SELECT CONCAT(...)
    INTO OUTFILE '/tmp/outfile.tab'
         FIELDS TERMINATED BY '\t'
         ESCAPED BY ''
    FROM tableA
   INNER
    JOIN tableB
      ON tableA.ID_1 = tableB.ID_1
     AND tableA.ID_2 = tableB.ID_2
   WHERE tableB.Value_1 - 1 = tableB.Value_2
     AND tableA.ID_1 !=
          ( SELECT DISTINCT
                   ID_1
              FROM tableB
             WHERE ID_1 = tableA.ID_1
               AND Value_1 = Value_2
          )
  ;
  </code></pre>
  
  <p>One final note: we issue all commands through putty, in which we can access MySQL</p>