Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DELETE Query is not working...

Posted on 2004-10-20
4
Medium Priority
?
1,215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

610 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