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

Delete Query with an Inner Join

4
Purpose:
This is a Distribution List database.

Function:
Users create many different email distribution lists, tailoring each to fit their specific needs

Wanted:
Users can combine multiple distribution lists to create new ones. Sometimes, however, they discover they've made a mistake. Users would like to delete from a new distribution list only the records that belong to an old one.

Technique (Short)
I've created a query (qry_PeopleJoinDistro) that identifies all records in the new distribution list.

I have created a second query which looks at all the records in the new Distribution list (qry_PeopleJoinDistro) and identifies only those which are also contained in an old Distribution list. This second query is called qry_Distro_Analytics_ByDistroList.

A schematic of this would look like two overlapping circles. Each circle represents a Distribution list. The intersecting region would represent those records contained in both.

My goal would be to delete overlapping records from the new distribution list ONLY. After removing these records, the schematic represented by two circles above would no longer have an intersecting region.


Technique (Long)- Let the Madness Begin!

A query selects the records in a new distribution list with the query called, "qry_PeopleJoinDistro", which is based on an open user form.

These records are narrowed, according to old distribution lists, with a second user controlled field called "[Forms]![frm_Distro_DashBoard_Super]![txtDistroList]"

The Select Query Looks Like this:

SELECT
tbl_Distro_Join_People.Distribution_List, tbl_Distro_Join_People.People
FROM
(tbl_People INNER JOIN qry_PeopleJoinDistro ON tbl_People.[Personal Contact Serial] = qry_PeopleJoinDistro.[Personal Contact Serial]) INNER JOIN tbl_Distro_Join_People ON tbl_People.[Personal Contact Serial] = tbl_Distro_Join_People.People
WHERE (((tbl_Distro_Join_People.Distribution_List)=[Forms]![frm_Distro_DashBoard_Super]![txtDistroList]) AND ((tbl_Distro_Join_People.People)=[qry_PeopleJoinDistro]![Personal Contact Serial]));
Summary of My Problem:
Turn the SELECT query above into a DELETE query. Records should be removed from tbl_Distro_Join_People.
Apr 19 '08 #1
1 3239
ADezii
8,834 Expert 8TB
Purpose:
This is a Distribution List database.

Function:
Users create many different email distribution lists, tailoring each to fit their specific needs

Wanted:
Users can combine multiple distribution lists to create new ones. Sometimes, however, they discover they've made a mistake. Users would like to delete from a new distribution list only the records that belong to an old one.

Technique (Short)
I've created a query (qry_PeopleJoinDistro) that identifies all records in the new distribution list.

I have created a second query which looks at all the records in the new Distribution list (qry_PeopleJoinDistro) and identifies only those which are also contained in an old Distribution list. This second query is called qry_Distro_Analytics_ByDistroList.

A schematic of this would look like two overlapping circles. Each circle represents a Distribution list. The intersecting region would represent those records contained in both.

My goal would be to delete overlapping records from the new distribution list ONLY. After removing these records, the schematic represented by two circles above would no longer have an intersecting region.


Technique (Long)- Let the Madness Begin!

A query selects the records in a new distribution list with the query called, "qry_PeopleJoinDistro", which is based on an open user form.

These records are narrowed, according to old distribution lists, with a second user controlled field called "[Forms]![frm_Distro_DashBoard_Super]![txtDistroList]"

The Select Query Looks Like this:

SELECT
tbl_Distro_Join_People.Distribution_List, tbl_Distro_Join_People.People
FROM
(tbl_People INNER JOIN qry_PeopleJoinDistro ON tbl_People.[Personal Contact Serial] = qry_PeopleJoinDistro.[Personal Contact Serial]) INNER JOIN tbl_Distro_Join_People ON tbl_People.[Personal Contact Serial] = tbl_Distro_Join_People.People
WHERE (((tbl_Distro_Join_People.Distribution_List)=[Forms]![frm_Distro_DashBoard_Super]![txtDistroList]) AND ((tbl_Distro_Join_People.People)=[qry_PeopleJoinDistro]![Personal Contact Serial]));
Summary of My Problem:
Turn the SELECT query above into a DELETE query. Records should be removed from tbl_Distro_Join_People.
This looks like the perfect situation for a Sub-Query. The following Query will Delete all Records in tblDistributionList_New that have identical Records in tblDistributionList_Old based on the [DistributionID] Field. You should be able to adapt the SQL for your specific needs:
Expand|Select|Wrap|Line Numbers
  1. DELETE  FROM tblDistributionList_New
  2. WHERE EXISTS 
  3. (SELECT [DistributionID]                                       
  4. FROM tblDistributionList_Old                                     
  5. WHERE tblDistributionList_Old.[DistributionID] = tblDistributionList_New.[DistributionID]); 
Apr 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Yossi Naggar | last post by:
Hello to everyone, I am an experienced user in MSSQL Server. Lately I have been started using MySQL. I managed to create my database and tables. When I wanted to execute the following query:...
0
by: Clay Luther | last post by:
Again, we have an odd performance problem with PGSQL, 7.4b2. Here is the query: delete from numplan where pkid in (select numplan.pkid from numplan left outer join pilothuntgroup on...
3
by: William Case | last post by:
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...
2
by: Dave Burt | last post by:
Hi, Access officionados, I'm new here, so please cut me slack/gently tell me off if I'm out of line or in the wrong place. OK, here's something that seems silly (and is also problematic to...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
1
by: Simon Harris | last post by:
I'm using Access2000 and I've got a problem with a delete query which I'm *sure* I had working before )-: I have a table (logfile) which I import from an external source that has a load of stuff I...
2
by: NoSpam | last post by:
Hi, I am working with C# and ASP.NET with code behind and a SQL Server. I'm making an e-shop. When clients see what they have in their basket, I added a function DELETE to delete a line. It took...
1
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data...
3
by: jpatchak | last post by:
The following select query gives me the set of records I want to delete: SELECT tblCaseNumbers.* FROM (tblCaseNumberDump INNER JOIN ON tblCaseNumberDump.SSN = .) INNER JOIN tblCaseNumbers ON . =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...

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.