title: Merge statement for stocks using three tables
body: <p>Here is the SQL Query:</p>
  
  <pre><code>MERGE  tblProductsSold
  
  USING tblOrders on tblOrders.OrderID = tblProductsSold.txtOrderID
  
  WHEN NOT MATCHED THEN 
  
  Insert ( txtOrderID, txtOrderdate, txtPartno, txtQty)  
  values 
  (SELECT tblItemsOnOrder.txtOrderID, 
   tblOrders.txtDateTime, 
   tblItemsOnOrder.txtPartNO, 
   tblItemsOnOrder.txtQTY
  FROM tblOrders  INNER JOIN tblItemsOnOrder 
  ON tblOrders.OrderID = tblItemsOnOrder.txtOrderID
  WHERE tblOrders.txtIsConfirmed = '1'
  )
  
  OUTPUT $action ;
  </code></pre>
  
  <p>Desired Result: need to import orders with <code>Products</code> that are not already in the <code>tblProductsSold</code> table</p>