473,587 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete Non Matching Records

Hi all,

I have two tables that are related to each other.
One has 30K records while the other has 500.
I ran a 'Without Matching' query to find records in the larger table
that didn't have a matching record in the smaller table, however now I
want to delete those records. Is there an easy way to do this?

Thanks,
Bill

May 2 '06 #1
3 3056
turn the select query into a delete query?

May 2 '06 #2
Great! Thanks so much. Works just fine.

(Just goes to show how much I have to learn!)

Bill

May 2 '06 #3
kl*****@hotmail .com wrote:
I have two tables that are related to each other.
One has 30K records while the other has 500.
I ran a 'Without Matching' query to find records in the larger table
that didn't have a matching record in the smaller table, however now I
want to delete those records. Is there an easy way to do this?


Bill - not a direct answer to your question, but I would refer you to
the recent "Relationsh ips. Does anyone use them?" thread. After you've
gotten rid of your orphaned records, to avoid future occurances, set up
a relationship to enforce referential integrity between the two tables.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
May 2 '06 #4

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

Similar topics

7
2979
by: Philip Mette | last post by:
I have been searching many postings and I cant seem to find anyone that has this answer so I decided to post. I am using SQL (Transact-SQL).If I have 2 tables with columns acct_num,activity_date,and pay_amt and I want to delete one instance of a record in table 1 for every instance of that record in table 2 how could I do that. For example. ...
2
1614
by: laurenq uantrell | last post by:
I'm hoping someone can tell me how to construct a stored procedure that deletes all records in tblA not matching the PK in tblB This gives me the recordset of all records in tblA with no matching records in tblB (ID is the PK in tblB) SELECT a.ID FROM dbo.tblB b RIGHT OUTER JOIN dbo.tblA a ON b.ID = a.ID WHERE
3
3318
by: Earl Teigrob | last post by:
I am considering writing a Class that Selects, Adds, Updates and Deletes Nodes in an XML File but do not what to reinvent the wheel. (See XML file below) That data format would emulate records in a Database Table with a Primary Key for each Record (see xml sample below) and a flat file structure. I would use a class to manipulate this type...
10
17785
by: D. Dante Lorenso | last post by:
I'd like to run a clean up command on my tables to eliminate rows that I'm no longer using in the database. I want to do something like this: DELETE FROM tablename WHERE IS_REFERENCED_BY_FOREIGN_KEY IS FALSE; Does anyone know how something like this could be done in PostgreSQL? I know I can search all the tables that
9
10619
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the table from which I want to delete has two foreign keys that references two other tables and it is also referenced by another table. But this...
2
11193
by: Joe Del Medico | last post by:
I have two tables A & B and I want to delete all the records in A that are not in B. Can I do this in the query builder? It seems like a simple problem. I can easily find the records in A that aren't in B by using the query wizard to come up with a query "A without matching B". I added table A to the query builder and Query "A without...
0
1107
by: debulle | last post by:
Hello, can somebody help. I've got one table (table1) with articleID, StoreID, DateFrom, DateTo and another table (table2) which has the exact layout, but holds a limited number of records. I want to delete all matching records in table2. So if a record in table2 is identical to one in table1, I would like to delete it from table1. Thanx...
2
1783
by: Phil Stanton | last post by:
Deleting a record on a membership form. Does some VB checks to see if the family are still in the list. Warns me there is no going back if I delete the record, so I say OK and it appears to delete OK. Record count goes down by 1, but if I select "ShowAllRecords", there he is back and the recordCount back to the original value Theories...
3
3519
by: Phil Stanton | last post by:
I have a form based on a complex query (Lots of tables) If I delete a record, everything appears to be OK. Get the message "Youa are about to delete 1 record ....". I say yes. The record count goes down correctly. Then if I do Records-->Remove Filter/Sort there are the deleted records back as if they had never been deleted. Same thin exactly...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.