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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete From table where exists (select...);

Status
Not open for further replies.

jckokko

Programmer
Jun 4, 2001
31
US
The table have total 17547 records.

Below query returns 1980 records:

SELECT DISTINCT [mytable].[SUB NO], [mytable].TAX, [mytable].DATE, [mytable_1].TAX, [mytable_1].DATE
FROM [mytable] INNER JOIN [mytable] AS [mytable_1] ON [mytable].[SUB NO] = [mytable_1].[SUB NO]
WHERE ((([mytable].TAX)="0") AND (([mytable].DATE)="25-JUL-07") AND (([mytable_1].TAX)="0") AND (([mytable_1].DATE)="25-JUN-07"));

But,
DELETE FROM mytable
where exists (above select query);
returns 17547 records.

Why?
 
What is the PrimaryKey of mytable and which records you really want to delete ?

FYI, the Exists (above select query) is ALWAYS true ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top