title: How to display the list of categories which contain items in mysql
body: <p>I would like to ask how to display a list of categories which contain items. Categories without item linked from other table should not be displayed.
  Also,categories should be displayed according to the number of items.</p>
  
  <p>Please consider the two tables:</p>
  
  <pre><code>   |------- categorytbl----|
     cat_id  |    cat_name
      1      |    Pet
      2      |    Person
      3      |    Places
     -------------------------
  
     |------ itemstbl -----|
      item_id      item_description     cat_id
       1                John              2
       2                Peter             2
       3                 Cat              1
  </code></pre>
  
  <p>If I am going to query the above table, the output should be:</p>
  
  <p>Pet(1) , Person(2)</p>
  
  <p>And, I should not include Places category since it does not contain any item.</p>
  
  <p>I tried my query:</p>
  
  <pre><code>   SELECT * FROM categorytbl a, itemstbl b WHERE a.cat_id=b.cat_id
  </code></pre>