title: how to prevent duplicates with inner join query (Postgres)
body: <p>I am trying to understand how to create a query to filter out some results based on an inner join.</p>
  
  <p>Consider the following data:</p>
  
  <pre><code>formulation_batch
  -----
  id  project_id  name    
  1   1           F1.1
  2   1           F1.2
  3   1           F1.3
  4   1           F1.all
  
  formulation_batch_component
  -----
  id  formulation_batch_id    component_id
  1   1                       1
  2   2                       2
  3   3                       3
  4   4                       1
  5   4                       2
  6   4                       3
  7   4                       4
  </code></pre>
  
  <p>I would like to select all formulation_batch records with a project_id of 1, and has a formulation_batch_component with a component_id of 1 or 2. So I run the following query:</p>
  
  <pre><code>SELECT formulation_batch.* 
  FROM formulation_batch 
  INNER JOIN formulation_batch_component
  ON formulation_batch.id = formulation_batch_component.formulation_batch_id
  WHERE formulation_batch.project_id = 1 
      AND ((formulation_batch_component.component_id = 2 
          OR formulation_batch_component.component_id = 1 ))
  </code></pre>
  
  <p>However, this returns a duplicate entry:</p>
  
  <pre><code>1;"F1.1"
  2;"F1.2"
  4;"F1.all"
  4;"F1.all"
  </code></pre>
  
  <p>Is there a way to modify this query so that I only get back the unique formulation_batch records which match the criteria?</p>
  
  <p>EG:</p>
  
  <pre><code>1;"F1.1"
  2;"F1.2"
  4;"F1.all"
  </code></pre>
  
  <p>Thanks for your time!</p>