473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

HELP! How to delete recods in one table that match those in another table?

I cannot believe I'm having this much trouble doing such a simple
thing!

I have two tables with identical structure. I can use an A2K select
query to show the records in table 1 that match those in table two
based on an inner join between two unindexed fields.

Here's the SQL code for the select query that DOES work:

SELECT tblEmailLetters_TEMP.*
FROM AAA_Temp_EmailImport INNER JOIN tblEmailLetters_TEMP ON
(AAA_Temp_EmailImport.MsgGroup = tblEmailLetters_TEMP.MsgGroup) AND
(AAA_Temp_EmailImport.MsgDesc = tblEmailLetters_TEMP.MsgDesc);

Here's what happens when I convert the above to a delete query:

DELETE tblEmailLetters_TEMP.*
FROM AAA_Temp_EmailImport INNER JOIN tblEmailLetters_TEMP ON
(AAA_Temp_EmailImport.MsgGroup = tblEmailLetters_TEMP.MsgGroup) AND
(AAA_Temp_EmailImport.MsgDesc = tblEmailLetters_TEMP.MsgDesc);

The delete version fails with a message that says "Could not delete
from specified tables."

I've done this successfully with other data base programs. Why does
this not work?

Thanks folks.
Nov 12 '05 #1
3 8073
On Fri, 10 Oct 2003 00:17:44 -0500, William Case
<re**********@nospam.zap> wrote:
I cannot believe I'm having this much trouble doing such a simple
thing!

I have two tables with identical structure. I can use an A2K select
query to show the records in table 1 that match those in table two
based on an inner join between two unindexed fields.


goto the relationships window and doubleclick on the relation between
those two tables. Now you see the two fields in relation. Down the
form you can choose three possibilities. I choose them all three.
Especially the last one is important for you I think: delete ...
Hopefully it works now.
--
bebelino

Nov 12 '05 #2
On Fri, 10 Oct 2003 07:34:40 GMT, bebelino <a.*@c.d> wrote:
On Fri, 10 Oct 2003 00:17:44 -0500, William Case
<re**********@nospam.zap> wrote:
I cannot believe I'm having this much trouble doing such a simple
thing!

I have two tables with identical structure. I can use an A2K select
query to show the records in table 1 that match those in table two
based on an inner join between two unindexed fields.


goto the relationships window and doubleclick on the relation between
those two tables. Now you see the two fields in relation. Down the
form you can choose three possibilities. I choose them all three.
Especially the last one is important for you I think: delete ...
Hopefully it works now.


Thanks for this response Bebelino! Are you saying that the query
fails BECAUSE the tables are not linked by a relationship? If so, I
can simply create a relationship on the fly even though BOTH of these
tables are temporary. Correct?
Nov 12 '05 #3
On Fri, 10 Oct 2003 11:59:39 -0500, LaurenW <re**********@nospam.zap>
wrote:
Thanks for this response Bebelino! Are you saying that the query
fails BECAUSE the tables are not linked by a relationship? If so, I
can simply create a relationship on the fly even though BOTH of these
tables are temporary. Correct?


I suggest you try it out, because I haven't don't this before. I would
access the tables via code and then delete the approriate records.
good luck,
--
bebelino
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CoOL! . | last post by:
Hello, I found the key to solve this problem in: http://darkstar.ist.utl.pt/mysql/doc/en/InnoDB_foreign_key_constraints.html You'll probably need an INDEX for that new foreign key you are...
4
by: Hartmut Jaeger | last post by:
I want to delete a MySQL table without using functions of the OS, so that my php script can run on any webserver. Can I use a command like $sql = "DELETE FROM tablename"; or are there better...
4
by: prasath03 | last post by:
Dear All, Can anybody help me about my coding, i'm inserting the image file to database using jsp. When i execute the code, the following error is occurred: java.sql.SQLException: Insert...
1
by: Bhavin mer | last post by:
delete first row from table Without where condition
1
by: oyster | last post by:
that is, there is no TABLE tag between a TABLE, for example <table >something with out table tag</table> what is the RE pattern? thanks the following is not right <table.*?>*?</table>
6
by: =?iso-8859-1?q?C=E9dric_Lucantis?= | last post by:
Le Thursday 26 June 2008 15:53:06 oyster, vous avez écrit : The construct does not match a whole word but only one char, so means "any char which is not t, a, b, l or e". Anyway the inside...
0
by: aswaditya | last post by:
Hi, I am new to SSIS packages. I have 6 Excel workbooks with data spread over two worksheets each and i have to map individual data to individual SQL tables. Please note that each worksheet is...
2
by: anoop s | last post by:
I want to delete records of one table that exist in another table. The tables have no primary key. It will take a lot of time compare field by field. Is there any method record by record comparison...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.