UnMatched Query to Delete Records (1 Viewer)

Trilback

Registered User.
Local time
Today, 12:57
Joined
Nov 29, 2013
Messages
88
I have a Unmatched query that displays what I need but I want to clean up my database and remove them but its not letting me. See sql below.


Code:
DELETE Warranty
FROM Warranty LEFT JOIN Serials_Repair ON Warranty.[Serial] = Serials_Repair.[Serials_Repair]
WHERE (((Serials_Repair.Serials_Repair) Is Null));


I changed "Delete" it was "Select" thinking that would work but it does not. Also see screen shot.
 

Attachments

  • Error.PNG
    Error.PNG
    81.3 KB · Views: 156

CJ_London

Super Moderator
Staff member
Local time
Today, 17:57
Joined
Feb 19, 2013
Messages
16,713
Basically the error message is telling you that you have two tables and it cannot determine which record to delete.

Try this as an alternative


Code:
DELETE *
FROM Warranty
WHERE Exists(SELECT * FROM Serials_Repair WHERE Serials_Repair.Serials_Repair=Warranty.[Serial])=False

Just noted you have a field name the same as the table name - this will also cause issues, suggest change the field name to something else
 
Last edited:

Trilback

Registered User.
Local time
Today, 12:57
Joined
Nov 29, 2013
Messages
88
Basically the error message is telling you that you have two tables and it cannot determine which record to delete.

Try this as an alternative


Code:
DELETE *
FROM Warranty
WHERE Exists(SELECT * FROM Serials_Repair WHERE Serials_Repair.Serials_Repair=Warranty.[Serial])=False

Just noted you have a field name the same as the table name - this will also cause issues, suggest change the field name to something else

It worked but did not. I took a few serials from my list but the first one I did show in the list but a couple others I check did. I will take your second suggestion and see if that works if not I will just upload my Warranty Table as I made a backup before I ran it.
 

Trilback

Registered User.
Local time
Today, 12:57
Joined
Nov 29, 2013
Messages
88
It worked but did not. I took a few serials from my list but the first one I did show in the list but a couple others I check did. I will take your second suggestion and see if that works if not I will just upload my Warranty Table as I made a backup before I ran it.

Thanks for the help think I had a duplicate serial which I should not as I scan the serial of the machine at work. So hmmm. Will have to look at that when I get to work.
 

Users who are viewing this thread

Top Bottom