Solved

DELETE Query is not working...

Posted on 2004-10-20
4
1,208 Views
Last Modified: 2007-12-19
Hi Guys,
This is a problem I already solved, but I still have no idea why I had the problem in the first place,
so I am asking you to explain what was wrong with my query.

The query deletes records from table1 based on some joins with table2.
The exactly same SELECT works perfectly, but the deletion, gives me an error that I need to specify a table, or that I cannot delete from this table.
Here's the query:

    DELETE table1.*
    FROM table1 INNER JOIN table2 ON (table1.name=table2.name) AND (table1.address=table2.address)
    WHERE (((table1.email) Is Not Null))

the Preview shows the correct answers, and if I make it a SELECT instead of DELETE, it shows all the rows correctly too.
But this query cannot be executed...

The way I solved it was:

DELETE *
FROM table1
WHERE ID IN
(
    SELECT table1.ID
    FROM table1 INNER JOIN table2 ON (table1.name=table2.name) AND (table1.address=table2.address)
    WHERE (((table1.email) Is Not Null))
);

Now, can anybody PLEASE explain why the hell didn't the first query work?!
0
Comment
Question by:Boris Aranovich
  • 2
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12355756
You cannot delete using a query with joins - that's just the way it is unfortunately. Essentially, the engine doesn't know which table(s) you want to delete from even if you specify it with the table1.*.
0
 
LVL 3

Author Comment

by:Boris Aranovich
ID: 12355767
That's what I thought...
But, this is a bit stupid, IMHO...
"DELETE table1.* FROM table1" should be clear enough for the engine to know what am I trying to delete...
Besides, the documentation of Access wrote that I can use JOIN in _any_ FROM statement...
Couldn't find there anything that will explain that it could break the query... :/
Oh well... it's unfortunate that sometimes I have to use Access for ease of work, because of the visual interface and etc.

Is there a way that I can integrate MS Access interface (application) with some MySQL database perhaps, and MySQL syntax queries?
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12355788
I'm not really familiar with MySQL but Access works just fine as a front end to MySQL - you could run your queries as pass-through queries assuming MySQL supports that kind of thing - sorry, I've never used it in this way, but I know many people have used it as a back end (I use SQL Server when I have to, personally).
0
 
LVL 3

Author Comment

by:Boris Aranovich
ID: 12355804
Alright, thanks a lot, I will explore and try to figure how it works.
If I won't manage, I know where to come back to ask questions ;)
Thanks again.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 89
ms access 2010 vba, copy table from db1 to db2 from db3 27 46
Programmer 14 49
Dirty form - conditional formatting 5 25
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question