title: how to select only 1 unique data when joining two tables, if the table structure is one to many?
body: <p>i am using an oracle database, i have two tables.</p>
  
  <p>table A
  primary key = productid</p>
  
  <p>table B 
  references productid of table A</p>
  
  <p>primary key = imageid</p>
  
  <p>flow:</p>
  
  <p>each product should have 4 images stored in the table B (mandatory)</p>
  
  <p>problem:</p>
  
  <p>there are some products that has only 2 or sometimes 3 or sometimes 1 image only
  despite of the fact that the 4 images rule is mandatory based from code level.</p>
  
  <p>Question:</p>
  
  <p>how to count unique number of products that has images in table b?Because, if I do</p>
  
  <p><code>select count(*) from tableA join tableB on tableA.productid = tableB.productid</code></p>
  
  <p>the result is double, because it's a one to many...as in , one product has many images.
  So let's say <code>productID = 12345</code> has <code>4 images</code> in <code>table B</code>, once I ran my query, the result is 4 , when i want to only get 1...so how?</p>