title: mysql select query on two tables
body: <p>I am trying to get a result from two tables without having a second query nested inside the first query loop.</p>
  
  <p>I have a table <em>products</em>:</p>
  
  <pre><code>product_code_1234 | product_name | otherfields...
  </code></pre>
  
  <p>And a table <em>categories</em>, where a product can have multiple categories:</p>
  
  <pre><code>category_name_1 | product_code_1234
  category_name_2 | product_code_1234
  category_name_3 | product_code_1234
  </code></pre>
  
  <p>Is there a query to get the following result?</p>
  
  <pre><code>product_code_1234 | product_name | ... | category_name_1 | category_name_2 | category_name_3
  </code></pre>