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