title: MySQL Get only first match of a conditions between 3 columns
body: <p>I am working with an API REST (NodeJS) that have access to a MySQL DB.
  In this database, there is a table that looks like this (let's name it <strong>Table_01</strong>):</p>
  <pre><code>| C_0| C_1| C_2| C_3| 
  |  1 | A1 | B1 |  1 |
  |  2 | A1 | B2 |  0 |
  |  3 | B1 | A1 |  0 |
  |  4 | A2 | B1 |  0 |
  |  5 | B2 | A1 |  1 |
  |  6 | B1 | A1 |  0 |
  |  7 | B3 | A1 |  0 |
  |  8 | A1 | B3 |  1 |
  |  9 | A3 | B1 |  0 |
  | 10 | A1 | B3 |  1 |
  | 11 | A1 | B1 |  0 |
  </code></pre>
  <p>My objective is to get the first match of a Value = 1 on C_3 for a pair of values in C_1 and C_2.</p>
  <p>Let's put an example.</p>
  <p>I want to know in what cases <strong>A_1 in C_1</strong>, have a <strong>1 in C_3</strong> (only the first match)</p>
  <p>So, in this case, the result should be:</p>
  <pre><code>A1 B1 1
  A1 B3 1
  </code></pre>
  <p>In JSON format:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>result = [
    {
      "C_1": "A1",
      "C_2": "B1",
      "C_3": "1",
    },
    {
      "C_1": "A1",
      "C_2": "B3",
      "C_3": "1",
    }
  ];</code></pre>
  </div>
  </div>
  </p>
  <p>I don't want to receive TWO times the second one, since A1 B3 = 1 is included 2 times in the table.</p>
  <p>I can get the result doing this:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>db.query('SELECT * FROM `Table_01` WHERE (`C_1` = A1 AND `C_2` = '+db.escape(value)+') AND `C_3` = 1',
    (err, res) =&gt; {
      ..
    }
  );</code></pre>
  </div>
  </div>
  </p>
  <p>But this would give me a third entry with the duplicated A1 B3 1.</p>
  <p>Obviously in this example is not very important.. But with a table full of rows, this is important to avoid very large responses and a posterior JS filter.</p>