Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Would appreciate another set of eyes to review and determine what is wrong here 1

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
Would appreciate another set of eyes to review and determine what is wrong here

The most frustrating part about this is this query has ran correctly for the last 3 years with no issues then is started deleting records I don’t want deleted.
The 2nd most frustrating part is I cannot find the problem.

Wanting to delete specific records that the account number is not equal to 212044110106 or is not equal to 212044110107. The query I'm using is

DELETE Tbl_DetailedSalesData.Lift_or_Part, Tbl_DetailedSalesData.[Acct#], Tbl_DetailedSalesData.*
FROM Tbl_DetailedSalesData
WHERE (((Tbl_DetailedSalesData.Lift_or_Part)="L") AND ((Tbl_DetailedSalesData.[Acct#])<>212044110106)) OR (((Tbl_DetailedSalesData.Lift_or_Part)="L") AND ((Tbl_DetailedSalesData.[Acct#])<>212044110107));

Sample Data

Lift_or_Part Acct# Invoice_Date Order_Type
L 212044110107 12/4/2014 LRY
L 212044110106 3/10/2014 LRY
L 212044110107 10/30/2014 LRY
L 212044110106 9/26/2014 LRY
L 212044110106 8/20/2014 LRY
L 212044110106 6/27/2014 LRY
L 212044110106 6/30/2014 LRY
L 212044110106 10/17/2014 LRY
L 212044110106 3/31/2014 LRY
L 212044110106 6/30/2014 LRY
L 212044110106 3/27/2014 LRY
L 212044110106 10/31/2014 LRY
L 212044110106 6/30/2014 LRY
L 212044110106 4/24/2014 LRY
L 212044110106 9/25/2014
L 212044110106 7/31/2014 LRY
L 212044110106 6/20/2014
L 212044110106 4/21/2014 LRY
L 212544110112 4/23/2014 LRY
L 212044110107 12/4/2014 LRY
L 212544110110 8/4/2014 LRY
L 212044110106 3/12/2014 LRY
L 212044110106 8/14/2014 LRY
L 212044110107 6/20/2014 LFP
L 212044110106 5/13/2014 LRY
L 212044110106 9/29/2014 LRY
L 212044110106 9/29/2014 LRY
L 212044110106 4/29/2014 LRY
L 212544110110 11/26/2014 LRY
L 212044110106 6/30/2014 LRY
L 212544110110 11/11/2014 LRY
L 212044110106 10/20/2014 LRY
L 212044110106 4/11/2014 LFP
L 236544401000 6/30/2014 LRY
L 212044110106 9/23/2014 LFP
L 212044110107 10/30/2014 LRY
L 212044110106 8/25/2014 LFP
L 230144303300 9/9/2014 LRY
L 212544110110 9/30/2014 LRY
L 212544110110 3/19/2014 LRY
L 212044110106 7/31/2014 LFP
L 212044110107 10/7/2014 LRY
L 212544110110 9/9/2014 LRY
L 212544110110 3/19/2014 LRY
L 212044110107 10/7/2014 LRY
L 212044110106 9/25/2014
L 212044110106 9/25/2014 LRY
L 212044110106 1/14/2015 LRY
L 212044110106 3/26/2014 LRY
L 212044110106 5/28/2014 LFP
L 212044110106 1/30/2015 LRY
L 212044110106 3/31/2014 LFP
L 212044110107 12/22/2014 LRY
L 212044110106 12/11/2014 LRY
L 212044110106 5/19/2014 LRY
L 212044110106 2/19/2014 LRY
L 212044110106 9/30/2014 LRY
L 212044110106 9/30/2014 LRY
L 212044110106 1/23/2015 LRY
L 212044110106 9/30/2014 LRY
L 212044110106 1/23/2015 LRY
L 212044110106 7/31/2014 LRY
L 236544401000 10/31/2014 LRY
L 212044110106 12/31/2014
L 212044110107 12/22/2014 LRY
L 212544110110 5/21/2014 LRY
L 212544110110 10/9/2014 LRY
L 212044110106 9/30/2014 LRY
L 212044110107 6/20/2014 LFP
L 212044110106 6/30/2014 LRY
 
How about:

[pre]
DELETE FROM Tbl_DetailedSalesData
WHERE Lift_or_Part = "L"
AND [Acct#] NOT IN (212044110106, 212044110107)
[/pre]

Would that work? :)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top