472,357 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,357 software developers and data experts.

Duplicate Field Script

Hello, i need some help if possible...
i have a payments table with over 500 records
i want to run a query that searches through the table spotting out any
duplicate ID#'s and Dates.
So basically it will run a search spotting out duplicate ID#'s. Than
with in those ID#'s spot out duplicate dates.
I could do this by eye and spend hours spotting out the duplicated
dates, but it would be much easier and funner having a script do it
for you.

Heres my example:

tblPay

ID \ DATE
---------------------
1.\ 123 \ 3-4-2004
2.\ 231 \ 3-4-2004
3.\ 456 \ 3-7-2004
4.\ 123 \ 3-4-2004
5.\ 456 \ 3-8-2004
6.\ 456 \ 3-7-2004
7.\ 124 \ 3-3-2004

the query will pull out the duplicate ID's:
which will end up with:
ID \ DATE
---------------------
1.\ 123 \ 3-4-2004
2.\ 123 \ 3-4-2004
3.\ 456 \ 3-7-2004
4.\ 456 \ 3-8-2004
5.\ 456 \ 3-7-2004

Than with in that it will pull out only the ones with duplicate dates:

ID \ DATE
---------------------
1.\ 123 \ 3-4-2004
2.\ 123 \ 3-4-2004
3.\ 456 \ 3-7-2004
4.\ 456 \ 3-7-2004

Any ideas on a script that can do this?

heres some theory:

Since i alreadt have one table [tblID] with a record of every unique
ID (non-duplicate) i can use that as a reference:
logic:
For x = 0 to EOF 'In tblID
vID= "Select [ID] from [tblID]"
IDcount= "Select Count([ID]) as CountID from [tblPAY] WHERE [ID]= vID"
IF IDcount > 1 Then 'Its a duplicate
arrayID(x) = vID 'Record ID in an Array
End IF
Next X
'Now i run a loop Through the array of ID's and select the dates
matching
For y = array(1) to array(end)
vDate = select date from tblPay where ID = array(1-end)
if vDate is a duplicate Then
'Record the vID and vDate as a record
Next y
' Finally when done i should have 1 table with only duplicated records
Jul 17 '05 #1
3 3114
gi*******@hotmail.com (Giloosh) wrote in message news:<ca**************************@posting.google. com>...
Hello, i need some help if possible...
i have a payments table with over 500 records
i want to run a query that searches through the table spotting out any
duplicate ID#'s and Dates.
So basically it will run a search spotting out duplicate ID#'s. Than
with in those ID#'s spot out duplicate dates.


try this

select [id],[date] from thetable
group by [id],[date]
having count(*)>1
Jul 17 '05 #2
wow that was a big help, now the dates are in order with the ID's. Is
that what u were aiming for it to do? IF so its a big start. Now
instead of looking through it manually i need to code up a script that
will spot out the duplicate records (id = id and date = date)
Thanks
Gil
bu*******@earthlink.net (Bob Butler) wrote in message news:<fa*************************@posting.google.c om>...
gi*******@hotmail.com (Giloosh) wrote in message news:<ca**************************@posting.google. com>...
Hello, i need some help if possible...
i have a payments table with over 500 records
i want to run a query that searches through the table spotting out any
duplicate ID#'s and Dates.
So basically it will run a search spotting out duplicate ID#'s. Than
with in those ID#'s spot out duplicate dates.


try this

select [id],[date] from thetable
group by [id],[date]
having count(*)>1

Jul 17 '05 #3
gi*******@hotmail.com (Giloosh) wrote in message news:<ca**************************@posting.google. com>...
wow that was a big help, now the dates are in order with the ID's. Is
that what u were aiming for it to do?
no, that'd be
select [id],[date] from thetable order by [id],[date]
IF so its a big start. Now
instead of looking through it manually i need to code up a script that
will spot out the duplicate records (id = id and date = date)


the list you get from the select I posted should already be only those
that are duplicates
select [id],[date] from thetable
group by [id],[date]
having count(*)>1


if you want to guarntee that the list is sorted add
order by [id], [date]

I think Access returns them sorted anyway; sql server doesn't unless
you specify that
Jul 17 '05 #4

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

Similar topics

7
by: Lowell Kirsh | last post by:
I have a script which I use to find all duplicates of files within a given directory and all its subdirectories. It seems like it's longer than it needs to be but I can't figure out how to shorten...
1
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import...
1
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
8
by: Mark | last post by:
When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same...
8
by: mindwarp | last post by:
Hi, When a user submits / posts data my php script Inserts data into my database. If they refresh the script or click back and click submit again I get duplicate record. Is there an easy...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
1
by: rdsandy | last post by:
Hi, I have a table Risk, a table Mitigation and a table RiskArchive. I am taking the RiskID, Criticality and MitigationPlan fields from Risk, and MitigationActionID from Mitigation and inserting...
1
by: VinArt | last post by:
MS Acc 2003, XP Thank you in advance for any help. I have tables called "Makeup" and "Lines". Each makeup can have multiple lines. Goal is to create a new "makeup" with identical "lines"...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.