title: Select categories and sub-categories from the same table
body: <p>I am presented with a database scenario where I have to retrieve the Products and their Packages that are in a single table. 
  <strong>NOTE:</strong> the hierarchy is just one-level, e.g, Package1 => Cola. Package2 => Fries, Burger. Package3 => Coffee etc. i.e, two columns</p>
  
  <p>I have three tables: Products, Core, Hierarchy.</p>
  
  <p><strong>Products</strong> holds the products and the packages which consits of other products.</p>
  
  <p><strong><em>Core</em></strong> specifies whether it's a package or loose product.</p>
  
  <p><strong>Hierarchy</strong> specifies the Package ID </p>
  
  <p><a href="https://i.stack.imgur.com/VPOyr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VPOyr.png" alt="enter image description here"></a></p>
  
  <p>How can I select all packages and its products so that all products are grouped by their parent/package? (i.e. two columns)</p>
  
  <p>Desired output:</p>
  
  <p><a href="https://i.stack.imgur.com/UA175.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UA175.png" alt="enter image description here"></a></p>