title: Is it possible to merge these tables into one array value
body: <p>I'm trying to combine some data from three different tables into a usuable array but I'm stuck on how to approach this.</p>
  
  <p>First let me explain the structure:</p>
  
  <p>My 'main' table <code>snm_content</code> :</p>
  
  <p>I only want to use <code>id</code> here</p>
  
  <p><a href="https://i.stack.imgur.com/qVdqP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qVdqP.png" alt="enter image description here"></a></p>
  
  <p>Second table 'snm_fieldsandfilters_connections' :</p>
  
  <p><code>element_id</code> is important here, it has the same value as <code>id</code> in the next table</p>
  
  <p><a href="https://i.stack.imgur.com/gJVlT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gJVlT.png" alt="enter image description here"></a></p>
  
  <p>Third table 'snm_fieldsandfilters_elements':</p>
  
  <p>Here <code>item_id</code> is important and <code>item_id</code> is the same value as <code>id</code> in 'snm_content'</p>
  
  <p><a href="https://i.stack.imgur.com/dj1PS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dj1PS.png" alt="enter image description here"></a></p>
  
  <p>So for example I add another article (the items in snm_content) which has <code>id</code> 4, then another row will be added in 'snm_fieldsandfilters_connections' with <code>element_id</code> 22 and there will also be another row added to 'snm_fieldsandfilters_elements' with <code>id</code> 22 and <code>item_id</code> 4.</p>
  
  <p>How can I get <code>element_id</code> from'snm_fieldsandfilters_connections' to match the <code>id</code> in 'snm_fieldsandfilters_elements'? And then compare <code>id</code> from 'snm_content' with <code>item_id</code> from 'snm_fieldsandfilters_elements'.</p>
  
  <p>I hope I explained it well enough.</p>
  
  <p>What is the best way to achieve this? (I mean SQL wise)</p>
  
  <p>Thanks to the answer I figured out how to do it.</p>
  
  <p>SOLUTION: </p>
  
  <pre><code>select ct.*, fe.*, cn.*
  from snm_content ct
  inner join snm_fieldsandfilters_elements fe on fe.item_id = ct.id
  inner join snm_fieldsandfilters_connections cn on cn.element_id = fe.id
  WHERE ct.catid IN ('10')
  </code></pre>