PC Review


Reply
Thread Tools Rate Thread

Delete Records from Table using Query Results

 
 
SITCFanTN
Guest
Posts: n/a
 
      7th May 2010
I have a table named "Records" that contains a field "Customer Number". I
need to delete all the records in table "Records" if the "Customer Number" is
also in the table named "Transfer". Is there a simple way to accomplish
this? Thank you!
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      7th May 2010
Use a delete query

DELETE
FROM Records
WHERE [Customer Number] in
(SELECT [Customer Number] FROM Transfer)

In query design view
== Add the table Records
== Select the customer number into the list of fields
== Select Query: Delete from the menu
== Enter the criteria under the customer number field
in (SELECT [Customer Number] FROM Transfer)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

SITCFanTN wrote:
> I have a table named "Records" that contains a field "Customer Number". I
> need to delete all the records in table "Records" if the "Customer Number" is
> also in the table named "Transfer". Is there a simple way to accomplish
> this? Thank you!

 
Reply With Quote
 
SITCFanTN
Guest
Posts: n/a
 
      10th May 2010
Hi John,

When I use the delete query you gave me, all the records I have in table
named "Records" are deleted. I just need the records deleted that contains a
duplicate "Customer Number" in the table "Records" and that also appear in
table "Transfer". Do you have any idea what I could be doing wrong. I'm
using exactly what you gave me below. As always I appreciate your help,
thank you.

"John Spencer" wrote:

> Use a delete query
>
> DELETE
> FROM Records
> WHERE [Customer Number] in
> (SELECT [Customer Number] FROM Transfer)
>
> In query design view
> == Add the table Records
> == Select the customer number into the list of fields
> == Select Query: Delete from the menu
> == Enter the criteria under the customer number field
> in (SELECT [Customer Number] FROM Transfer)
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> SITCFanTN wrote:
> > I have a table named "Records" that contains a field "Customer Number". I
> > need to delete all the records in table "Records" if the "Customer Number" is
> > also in the table named "Transfer". Is there a simple way to accomplish
> > this? Thank you!

> .
>

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      11th May 2010
That indicates to me that the table Transfer contains all the customer numbers
that are in the table Records. If that is the case you need a way to delete
just the duplicates.

The next step is to determine which records in the Records table you want to
keep. If you have several records with the Customer Number 12345, what
criteria would you use to determine which record to retain? Or does it matter
which record you retain?

There are several techniques that can be used depending on the design of your
database and what relationships (if any) are defined that involve the Records
table.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

SITCFanTN wrote:
> Hi John,
>
> When I use the delete query you gave me, all the records I have in table
> named "Records" are deleted. I just need the records deleted that contains a
> duplicate "Customer Number" in the table "Records" and that also appear in
> table "Transfer". Do you have any idea what I could be doing wrong. I'm
> using exactly what you gave me below. As always I appreciate your help,
> thank you.
>
> "John Spencer" wrote:
>
>> Use a delete query
>>
>> DELETE
>> FROM Records
>> WHERE [Customer Number] in
>> (SELECT [Customer Number] FROM Transfer)
>>
>> In query design view
>> == Add the table Records
>> == Select the customer number into the list of fields
>> == Select Query: Delete from the menu
>> == Enter the criteria under the customer number field
>> in (SELECT [Customer Number] FROM Transfer)
>>
>> John Spencer
>> Access MVP 2002-2005, 2007-2010
>> The Hilltop Institute
>> University of Maryland Baltimore County
>>
>> SITCFanTN wrote:
>>> I have a table named "Records" that contains a field "Customer Number". I
>>> need to delete all the records in table "Records" if the "Customer Number" is
>>> also in the table named "Transfer". Is there a simple way to accomplish
>>> this? Thank you!

>> .
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need query results showing Table 1 records both w/ and w/o matches in Table 2. Jesse Microsoft Access Queries 6 13th Aug 2007 05:10 AM
Delete query unable to delete records from table. Fix how? =?Utf-8?B?TG9uZ1RvbQ==?= Microsoft Access Queries 8 15th Apr 2007 11:29 AM
Delete Query - Delete records in Table 1 using parameters from Tab =?Utf-8?B?SmVu?= Microsoft Access Queries 2 21st Mar 2005 01:13 PM
Delete records based upon query results on another table Ryan Barnes Microsoft Access Queries 2 22nd Apr 2004 12:41 PM
Query from multiples table results in multiple records =?Utf-8?B?Q2FycGll?= Microsoft Access Queries 5 27th Jan 2004 05:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:17 AM.