title: SQL select categories where fields are set to show
body: <p>I am trying to select categories (only categories), where fiels (which are in separate table) have their show value set to 1.</p>
  
  <p>I managed to made it with INNER JOIN, but problem is, this will get everything (even the fields themselves), so when I try to use while and print categories, it prints one category as many times, as many fields is there.</p>
  
  <pre><code>$get_cats = dbquery("SELECT A.field_cat_name, A.field_cat_id FROM ".DB_USER_FIELD_CATS." A INNER JOIN ".DB_USER_FIELDS." B ON A.field_cat_id=B.field_cat WHERE B.field_show!='0' ORDER BY field_cat_order");
  
  while ($cat = dbarray($get_cats)){
      echo "&lt;div class='tester' id='cat-".$cat['field_cat_id']."'&gt;&lt;span&gt;".$cat['field_cat_name']."&lt;/span&gt;&lt;/div&gt;";
  }
  </code></pre>
  
  <p>Returns</p>
  
  <pre><code>CONTACT INFORMATION
  CONTACT INFORMATION
  CONTACT INFORMATION
  CONTACT INFORMATION
  CONTACT INFORMATION
  CONTACT INFORMATION
  CONTACT INFORMATION
  MISCELLANEOUS INFORMATION
  MISCELLANEOUS INFORMATION
  STATISTICS
  STATISTICS
  STATISTICS
  </code></pre>
  
  <p>Some ideas? I tried googling, but have no idea what to tell google to search, so it would show me relevant results.</p>
  
  <p><strong>TL;DR</strong></p>
  
  <p>I need to get all categories which have any fields that have show value set to 1. Categories and fields are in separate tables tho.</p>
  
  <p>Thanks.</p>