Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Overwrite existing record


Message #1 by "SpyderJonz" <ajjones13@m...> on Mon, 20 May 2002 17:07:34
Hello,

I would like over write an existing record.  The Code below deletes all 
records that are duplicates.  I wanted to delete just one, but that didn't 
work either!


sqlText = ("SELECT orderID, productID, quantity, pname " _
 & " FROM itemsordered  " _
 & " WHERE itemsordered.productID IN "  _


  & " (SELECT F.productID " _
  & " FROM itemsordered AS F " _
  & " WHERE Exists (SELECT orderID, productID, Count(productID) "  _
  & " FROM itemsordered " _
  & " WHERE itemsordered.orderID = F.orderID " _
  & " AND itemsordered.productID = F.productID " _
  & " GROUP BY itemsordered.orderID, itemsordered.productID " _
  & " HAVING Count(itemsordered.productID) > 1)) " _
  & " AND itemsordered.orderID NOT IN " _

  & "   (SELECT Min(productID) "_
  & "   FROM itemsordered AS F "_
  & "   WHERE Exists (SELECT orderID, productID, Count(productID) "_
  & "   FROM itemsordered "_
  & "   WHERE itemsordered.orderID = F.orderID "_
  & "   AND itemsordered.productID = F.productID "_
  & "   GROUP BY itemsordered.orderID, itemsordered.productID "_
  & "   HAVING Count(itemsordered.productID) > 0) "_
  & "   GROUP BY orderID, productID) ")

Conn.Execute(sqlText)


Thanks,
Spyder

  Return to Index