473,414 Members | 1,720 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,414 software developers and data experts.

delete query for unmatched records

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 matching B"
joined them with the index field (Loan Number) made the query a delete
query and
chose Table A.* in the grid. I am getting the error "Couldn't delete
from specified tables". It can't be a permission problem because I
have full control on the database.

The SQL view is this:

DELETE A.*
FROM A INNER JOIN [A Without Matching B] ON A.[Loan Number] = [A
Without Matching B].[Loan Number];

I could go through the table programatically and delete all loans in A
that come up in the query "A without matching B" but this seems very
time consuming.
Shouldn't there be a way to do this in the query builder or at least
with a written SQL statement?

Joe Del Medico jo*********@yahoo.com
Nov 12 '05 #1
2 11172
this should do it

DELETE *
FROM tblA
WHERE (((tblA.loanNumber) Not In (SELECT loanNumber from tblB)));
jo*********@yahoo.com (Joe Del Medico) wrote in message news:<29**************************@posting.google. com>...
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 matching B"
joined them with the index field (Loan Number) made the query a delete
query and
chose Table A.* in the grid. I am getting the error "Couldn't delete
from specified tables". It can't be a permission problem because I
have full control on the database.

The SQL view is this:

DELETE A.*
FROM A INNER JOIN [A Without Matching B] ON A.[Loan Number] = [A
Without Matching B].[Loan Number];

I could go through the table programatically and delete all loans in A
that come up in the query "A without matching B" but this seems very
time consuming.
Shouldn't there be a way to do this in the query builder or at least
with a written SQL statement?

Joe Del Medico jo*********@yahoo.com

Nov 12 '05 #2
Thanks Roger !
Joe

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

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

Similar topics

2
by: jh8735 | last post by:
I use Access to run reports from various pieces of financial data. The one query that I have been unable to produce, but need is the following: A query that yields all accounts from a person...
4
by: Akinia | last post by:
Hi every body I've a little problem with my query, I can't figure it out. I've three tables: Table A (EmployeNr, Date, Code) Table B (EmployeNr, Date, Code) Which is an historic of Table A...
2
by: Colleyville Alan | last post by:
I want to extract some records that are common to three tables, but not contained in the fourth. Following what I have see in the archives and also trying the unmatched records query wizard, if I...
5
by: Bob Weisenburger | last post by:
I have a table of "memos". each record in that table has a primary key "memo ID" that is autonumber. I have another table that is "memo receipts" with each record having a "receipt id" field that...
6
by: Sven Pran | last post by:
Probably the answer is there just in front of me only awaiting me to discover it, but: 1: I want to build a query that returns all records in one table for which there is no successful "join"...
8
by: paulwilliamsonremove | last post by:
Hi, Using Access 2003. I am trying to delete records from one table/query ("qryHistoryPersonIDs") if they don't exist in another table ("qryDonations"). But the SQL syntax I came up with is...
7
by: Jim | last post by:
How do I program visual basic to create a "Find Unmatched Query"? I have two tables: - TodaysImport - YesterdaysImport Both tables have the same 6 fields: - User
2
by: scolivas | last post by:
Is there a way to automate this process? I have a query that finds the "Drop Offs" by doing an unmatch query against the hard table and the live table. I want to automatically pull these...
11
beacon
by: beacon | last post by:
Hi everybody, I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.