title: Join returning duplicates
body: <p>I keep getting duplicates on my join statement , any join experts please help I have been scratching my head for hours </p>
  
  <pre><code>SELECT  
    DISTINCT  
    image.ImageID,
    Lotpw.Lot,
    lot.Oper,
    lot.Product,
    lot.Process,
    Image.PartialWafer,
    image.UnitX,
    image.UnitY,
    Image.InspectionStation,
    Image.Status,
    Image.ImagePath,
    image.Date,
  FROM Lot 
  --FROM [VueDb].[dbo].[Lot] join [VueDb].[dbo].[LotPW] on lot.Lot=lotpw.Lot join [VueDb].[dbo].[Image] on lotpw.PartialWafer = image.PartialWafer 
    LEFT JOIN LotPW 
      on lot.Lot = lotpw.Lot  
    RIGHT JOIN image 
      on LOTPW.partialwafer = Image.partialwafer
  
  WHERE (@Lot= '' or  Lot.Lot= @Lot)
    and (@Oper ='' or Lot.Oper= @Oper)
    and (@Product= '' or  Lot.Product= @Product)
    and (@Process= '' or Lot.Process= @Process)
    and (@PartialWafer= '' or  image.PartialWafer= @PartialWafer)
    and (@UnitX ='' or Image.UnitX= @UnitX)
    and (@UnitY= '' or Image.UnitY= @UnitY)
    and (@InspectionStation ='' or Image.InspectionStation = @InspectionStation)
    and (@Status ='' or Image.Status= @Status)
    and (@LossCode= '' or Image.LossCode= @LossCode)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/L2WGT.jpg" alt="enter image description here"></p>
  
  <p>below is an image of the output </p>