title: MYSQL SELECT: How to get an additional column that indicates whether the first or the second condition in a WHERE clause was met?
body: <p>How can I add a boolean column to a <code>SELECT</code> statement with a <code>WHERE</code> clause and to conditions combined with an <code>OR</code> that is 1 if the first condition was met and 0 if the second and not the first condition was met?</p>
  
  <p>As an example take the following table <code>t</code> with integer columns:</p>
  
  <pre><code>+----+---+---+
  | id | a | b |
  +----+---+---+
  |  1 | 2 | 3 |
  |  2 | 3 | 2 |
  |  3 | 5 | 2 |
  +----+---+---+
  </code></pre>
  
  <p>When I execute the statement <code>SELECT * FROM t WHERE a&lt;b OR b+1=a;</code> I get:</p>
  
  <pre><code>+----+---+---+
  | id | a | b |
  +----+---+---+
  |  1 | 2 | 3 |
  |  2 | 3 | 2 |
  +----+---+---+
  </code></pre>
  
  <p>And what I want is an additional column, say <code>cond</code>, like</p>
  
  <pre><code>+----+---+---+------+
  | id | a | b | cond |
  +----+---+---+------+
  |  1 | 2 | 3 |    1 |
  |  2 | 3 | 2 |    0 |
  +----+---+---+------+
  </code></pre>
  
  <p>How can this be achieved in MySQL?</p>