473,473 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create 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
"tblHurnsHistory." 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_creditsEarned

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.SyStudentID, HHDelete.Grads_creditsEarned, HHDelete.ID,
HHDelete.StudentName, HHDelete.SSN, HHDelete.adTrmCode,
HHDelete.GPA_creditsEarned, HHDelete.StatusDesc, HHDelete.StatusDate,
HHDelete.LDA, HHDelete.ProgVersCode, HHDelete.TermCode,
HHDelete.term_credits, HHDelete.TotalCrd, HHDelete.creditsAttempt,
HHDelete.GPA, HHDelete.CreditsRemaining, HHDelete.SumOfReceived,
HHDelete.SumOfRefunded, HHDelete.FundSource
FROM tblHurnsHistory AS HHDelete
WHERE (((HHDelete.SyStudentID) In (SELECT [SyStudentID] FROM
[qryHurnsHistory] As Tmp GROUP BY [SyStudentID],[Grads_creditsEarned]
HAVING Count(*)>1 And [Grads_creditsEarned] =
[qryHurnsHistory].[Grads_creditsEarned])));
Thanks in advance,

Justin

Oct 20 '06 #1
1 2006
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_count 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_count 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
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
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...
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...
13
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...
2
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,...
3
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...
1
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
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 . =...
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.