title: Each match in each columns of a table to array
body: <p>This is how my table <code>tables</code> looks:</p>
  
  <p><a href="https://i.stack.imgur.com/o8cNH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8cNH.png" alt="tables"></a><br>
  <sub>(source: <a href="https://laiteux.dev/pwq" rel="nofollow noreferrer">laiteux.dev</a>)</sub>  </p>
  
  <p>I basically want to make an API that will return every "table" the user (Admin, here) is in, by checking if he is either in <code>1_1</code>, <code>1_2</code>, <code>1_3</code>, <code>1_4</code> or <code>1_5</code>.</p>
  
  <p>This is how I tried to do it:</p>
  
  <pre class="lang-php prettyprint-override"><code>$positions = $database-&gt;fetchAll("SELECT * FROM tables WHERE 1_1 = :username OR 1_2 = :username OR 1_3 = :username OR 1_4 = :username OR 1_5 = :username", array(":username" =&gt; "Admin"));
  
  print_r($positions);
  </code></pre>
  
  <p>And this is what this do return:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 1
              [code] =&gt; abc123
              [1_1] =&gt; 
              [1_2] =&gt; Admin
              [1_3] =&gt; 
              [1_4] =&gt; Admin
              [1_5] =&gt; 
          )
  )
  </code></pre>
  
  <p>The problems are:</p>
  
  <ol>
  <li>The SQL query looks very unclean and long.</li>
  <li>If the user is in <code>1_2</code> and also in <code>1_4</code>, it won't return both results.</li>
  </ol>
  
  <p>I'd like my API to return such an array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [code] =&gt; abc123
              [location] =&gt; 1_2
          )
  
      [1] =&gt; Array
          (
              [code] =&gt; abc123
              [location] =&gt; 1_4
          )
  )
  </code></pre>
  
  <p>How could I please do it, in a clean way?</p>