 <p>try this...</p> <pre><code>select p.*, c.category_id, c.category_name, pcm.quantity from products p inner join product_categories_map pcm on p.product_id = pcm.product_id inner join categories c on pcm.category_id = c.category_id where c.code = 'something' order by p.product_id, c.category_id; </code></pre>