title: Storing an array of id's in one db field VS breaking out into a joining table - what sql to use?
body: <p>I have concluded that my first quick fix of storing an array of ids in a singular database field (1,5,48) is probably not best but if I break them out into a joining table of 'parent item id' (singular) and then sub related item id (multiple) which links to a separate table it would be better.</p>
  
  <p>But now I am unsure what mysql query to use to get matches.</p>
  
  <p>So a search form is submitted where "related_item" array is "1,5,8" and one of my "parent_items" has related item matches of "1" and "8" in the joining table....</p>
  
  <p>So what mysql query would return these matches?</p>
  
  <p>UPDATE:</p>
  
  <ul>
  <li>I have one table 'companies' maybe HSBC and TOPSHOP as example records.  </li>
  <li>There is a separate table of 'industries' maybe 'banking' and 'retail' </li>
  <li>There is a joining table which is company_id and industry_id which pairs them both together</li>
  </ul>
  
  <p>So if someone submits a search form for where industry = 'banking' or 'retail' how would I return the company records for 'topshop' and 'hsbc'</p>