?
Solved

DELETE Query is not working...

Posted on 2004-10-20
4
Medium Priority
?
1,212 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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