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

Home Posts Topics Members FAQ

Changing a duplicate select query into a delete query, help!!

JC
Hello,

I am trying to change a select, find duplicates, query into a delete
query. I want to get rid of the records in the main table
"tblHurnsHistor y." I changed the Find Duplicates query to a Delete
query. I then received an input box looking for criteria that
states,"

Enter parameter value
qryHurnsHistory .Grads_creditsE arned

Then it deletes 0 records. I need it to delete the 48 that the Find
Duplicates query returned.

I am a little rusty at SQL, can you help me so the following SQL
deletes the records returned by the FindDuplicates query.
DELETE HHDelete.SyStud entID, HHDelete.Grads_ creditsEarned, HHDelete.ID,
HHDelete.Studen tName, HHDelete.SSN, HHDelete.adTrmC ode,
HHDelete.GPA_cr editsEarned, HHDelete.Status Desc, HHDelete.Status Date,
HHDelete.LDA, HHDelete.ProgVe rsCode, HHDelete.TermCo de,
HHDelete.term_c redits, HHDelete.TotalC rd, HHDelete.credit sAttempt,
HHDelete.GPA, HHDelete.Credit sRemaining, HHDelete.SumOfR eceived,
HHDelete.SumOfR efunded, HHDelete.FundSo urce
FROM tblHurnsHistory AS HHDelete
WHERE (((HHDelete.SyS tudentID) In (SELECT [SyStudentID] FROM
[qryHurnsHistory] As Tmp GROUP BY [SyStudentID],[Grads_creditsEa rned]
HAVING Count(*)>1 And [Grads_creditsEa rned] =
[qryHurnsHistory].[Grads_creditsEa rned])));
Thanks in advance,

Justin

Oct 20 '06 #1
1 2026
I suspect you need to rewrite your query eliminating all group by
clauses, including any in qryHurnsHistory . Alas you do not state your
table's primary key. In the following example, the primary key is
my_table.my_id1 . My_table.my_cou nt and my_table.my_id2 are the
duplicated fields.

DELETE my_table.*
FROM my_table
WHERE ((((select count(*) from my_table b where b.my_id2 =
my_table.my_id2 and b.my_count = my_table.my_cou nt and my_table.my_id >
b.my_id))>0));

Above uses a subquery and is probably the style of query that you need.
Try help on 'subquery' and 'table alias' if you are new to the
technique.

Good Luck.
Breadon

Oct 23 '06 #2

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

Similar topics

3
1831
by: Adam | last post by:
Hello, I have a 2 column file that looks like this: VALUE1 | VALUE2 12 | 7 10 | 7 9 | 8 10 | 8 11 | 8 6 | 9 8 | 9
6
1954
by: Mark Reed | last post by:
Hi all, Please help. I have a table with 2 fields of which I am trying to change a select query into a delete query. the select query is: SELECT Table1.Date, Min(Table1.Ball) AS MinOfBall FROM Table1 GROUP BY Table1.Date;
1
2677
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 don't need. So I have another table (tests_not_reqd) that lists the tests I don't need. Link 'em together with an inner join to see the tests in 'logfile' that I don't need - all looking good so far ... SELECT Logfile.* FROM tests_not_reqd INNER...
13
2870
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything other than a select query using the Wizard? What do you think happened to her data? I am working remotely until Friday, so I can't get down to her office and check out what she did.
2
2264
by: jmarr02s | last post by:
I don't know what I am doing wrong I get duplicate records when I query Here is my SQL query code: SELECT Utilization_T.Facid, Utilization_T.Year, Utilization_T.Beds, Utilization_T.LicBeds, Utilization_T.NursingCare, Utilization_T.GenLicBeds, FormatDate(Now()) AS Expr1, Staffing_T.Username FROM Staffing_T INNER JOIN Utilization_T ON Staffing_T.facid = Utilization_T.Facid
3
3814
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get anything to work. I know this is probably simple for more experienced Access users. Any help would be greatly appreciated. Thanks Kevin
1
1707
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
3
1786
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 . = tblCaseNumbers.ProspectKey WHERE ((=IIf(Right(,1)='D','D',IIf(Right(,1)='A','PLP', IIf(Right(,1)='B','SLP','M'))))); When I try to make it a delete query however: DELETE tblCaseNumbers.* FROM (tblCaseNumberDump INNER JOIN ON...
1
1901
by: DontTell | last post by:
Hi - I am trying to delete duplicate records from a single table. The table has multilple records of duplicate purchase orders. In these instances I need to delete those records that have the same $amt but different qty. I have already created the delete query but am unsure how to specify the criteria which should be based on the $amt and qty. Simply said, I need the code to remove all Duplicates with the same $ but different qty. ...
0
9481
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8979
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.