Delete Query Criteria (1 Viewer)

NearImpossible

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 12, 2019
Messages
225
When trying to run the following delete query (Screen shot attached), I am getting "Specify the table containing the records you want to delete"

It is due to the Criteria entries and I don't know how to fix it.

Please advise

thank you
 

Attachments

  • query.PNG
    query.PNG
    92 KB · Views: 97

June7

AWF VIP
Local time
Yesterday, 20:10
Joined
Mar 9, 2014
Messages
5,463
Post the SQL statement, not just image of design.

It is not necessary to list table fields in DELETE action because the entire record is deleted.

DELETE FROM table WHERE some criteria here;

Perhaps you should do like:

DELETE FROM dbo_db_AddNewTicket WHERE TicketID IN (SELECT TicketID FROM Temp);

Why would TecnicianID be needed? Can each ticket have more than one technician associated? Don't see how if TicketID is primary key in main table.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 05:10
Joined
Jan 14, 2017
Messages
18,209
That should be:
Code:
DELETE [B][COLOR="DarkRed"]*[/COLOR][/B] FROM TableName WHERE some condition

OR if more than one table is involved in the query, something like:
Code:
DELETE [B][COLOR="DarkRed"]DISTINCTROW *[/COLOR][/B]  FROM TableName LEFT JOIN OtherTableName ON (TableName.FieldName =  OtherTableName.OtherFieldName WHERE some condition)
 
Last edited:

June7

AWF VIP
Local time
Yesterday, 20:10
Joined
Mar 9, 2014
Messages
5,463
Just as explicitly listing fields is not needed, neither is wildcard. Access query builder will throw it in if query object is saved (just as it will add bunches of unnecessary parens) but the action will run just fine without.
 

NearImpossible

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 12, 2019
Messages
225
Post the SQL statement, not just image of design.

It is not necessary to list table fields in DELETE action because the entire record is deleted.

DELETE FROM table WHERE some criteria here;

Perhaps you should do like:

DELETE FROM dbo_db_AddNewTicket WHERE TicketID IN (SELECT TicketID FROM Temp);

Why would TecnicianID be needed? Can each ticket have more than one technician associated? Don't see how if TicketID is primary key in main table.



DELETE FROM dbo_db_AddNewTicket WHERE TicketID IN (SELECT TicketID FROM Temp); worked like a charm, and I was using both columns in another query that I copied to make the delete query, but you are correct in stating that TechnicanID is not needed
 

isladogs

MVP / VIP
Local time
Today, 05:10
Joined
Jan 14, 2017
Messages
18,209
Just as explicitly listing fields is not needed, neither is wildcard. Access query builder will throw it in if query object is saved (just as it will add bunches of unnecessary parens) but the action will run just fine without.

I was assuming the delete query would be saved
 

Users who are viewing this thread

Top Bottom