title: PostgreSQL: How to get only the first result from a SELECT
body: <p>In my database, I have two columns, products, and products_photos, where products can have many products_photos. What I want to do is a query that returns the products but with only one photo.
  I manage to write a query like this:</p>
  <pre><code>SELECT products.*, file
  FROM products, products_photos
  WHERE products.id = products_photos.product_id
  ORDER BY products.id
  </code></pre>
  <p>But still, this returns the same product, multiple times, because of the photos.
  I already tried to use DISTINCT and LIMIT but does not work properly.</p>