• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1964
  • Last Modified:

Query must have at least one destination field - delete query

I'm trying to run the following delete query against my table:

DELETE FROM Reservation WHERE ReservationID=1112716201

ReserverationID is defined as a numeric (primary key) field.  There are no relationships between the tables in my database.  I'm not sure what this error means or how to adjust my query.
0
BKaporch
Asked:
BKaporch
  • 4
  • 2
  • 2
  • +4
1 Solution
 
Ryan ChongCommented:
Statement looks good, the problem maybe is on the scripts you execute that statement, can you post it here?
0
 
Ryan ChongCommented:
In additional, for executing a Delete statement, always try a Execute method, like:

...
SQLstr = "DELETE FROM Reservation WHERE ReservationID=1112716201"
conn.execute SQLstr
...
0
 
BKaporchAuthor Commented:
There were no scripts for the query, this was an ad-hoc query that I saved in the database.  
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
wzardCommented:
Some database management systems require (as this one also seems to do) that you format the delete statement as following:

delete * from reservation where reservationID=1112716201

Which DBMS are you actually using?
0
 
Ryan ChongCommented:
What's your database you using? Are you able to execute able statement in that database's query builder ? or you facing the problem as what stated on your question title when you try to execute it inside the database's query builder?

regards
0
 
BKaporchAuthor Commented:
I'm using Access.  The query is failing in query builder.  
0
 
Ryan ChongCommented:
I just done a test on my side, query executed successfully under my enviroment without problem, record is deleted successfully..

My suggestion is try to compact the Access database, and then try again your statement there...

If still not working, try to create a new empty database, import all database elements (tables, queries, reports, etc) from the current database to that new database, and then try execute your statement there.

Good Luck!
0
 
PBInsuranceCommented:
Bkaporch,
I'm not sure why your query isn't working. I recreated the table and query, and it deletes with no problems. My SQL string is below:

DELETE reservations.reservationID
FROM reservations
WHERE (((reservations.reservationID)=1112716201));

Good luck.
0
 
wzardCommented:
BKaporch
It was not hard to reproduce this error in access, i asume you use the querybuilder mostly for select-query's

When you try to use it for a select query, you use the button with the grid-symbol on it, which you also use to switch between SQL and querybuilderview (probably most left on the toolbar).

for delete insert and updatequery's you have to use the !-button (execute)  on the toolbar
or click the query-menu and click execute. you should now get a message whether you really want to delete a specified amount of records.

when deleting, you don't have any grid-columns defined, so no grid can be populated and this error will occur.

In fact, for all query's you may want to use the !-button.
The grid-button as describes before just displays the rows that will be selected, updated or inserted in the table and in fact does not do anything at all.

This will probably solve your problem...
Good luck
0
 
vanameisterCommented:
You need to describe what you want to delete after DELETE command... Thus use

DELETE [field u want to delete] FROM Reservation WHERE ReservationID=1112716201
instead
DELETE FROM Reservation WHERE ReservationID=1112716201

If you want to delete all ocurencies, use
DELETE * FROM Reservation WHERE ReservationID=1112716201

regards,
Raoul
0
 
SjoerdVerweijCommented:
wzard is right.
0
 
PBInsuranceCommented:
Wzard is correct. sometimes the simplest thing is the most overlooked.
0
 
jrb1Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: wzard

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

John Bush
EE Cleanup Volunteer
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now