If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Delete Records from Table using Query Results
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! |
#2
|
|||
|
|||
Delete Records from Table using Query Results
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! |
#3
|
|||
|
|||
Delete Records from Table using Query Results
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! . |
#4
|
|||
|
|||
Delete Records from Table using Query Results
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! . |
Thread Tools | |
Display Modes | |
|
|