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

Find duplicate records on two fields

Hi,

Please excuse the newbie type question, but I am wracking my brains to
solve what should be a simple query.

I have three fields in a table F1, F2, F3. Any of the fields may
contain duplicate data, but I am only interested in where only the
first two fields match. I want to query and get only the records (all
three fields) where there are duplicates in the first two fields, e.g.

F1 F2 F3
1 2 3
1 2 4
1 2 4
2 3 4
2 3 4

Would return only, 1 2 3, 1 2 4 (because there are more than one row
with 1 2) and not any of the records with 2 3.

Hope this comes out clear.

Thanks in advance
Steve in UK

Nov 13 '05 #1
2 5664
"steevp" <st******@hotmail.com> wrote in
news:11*********************@g14g2000cwa.googlegro ups.com:
Hi,

Please excuse the newbie type question, but I am wracking my
brains to solve what should be a simple query.

I have three fields in a table F1, F2, F3. Any of the fields
may contain duplicate data, but I am only interested in where
only the first two fields match. I want to query and get only
the records (all three fields) where there are duplicates in
the first two fields, e.g.

F1 F2 F3
1 2 3
1 2 4
1 2 4
2 3 4
2 3 4

Would return only, 1 2 3, 1 2 4 (because there are more than
one row with 1 2) and not any of the records with 2 3.

Hope this comes out clear.

Thanks in advance
Steve in UK


In the query, put two instances of the table. It will show the
table names as TableName and TableName_1. Right click on each
name and set the alias property to A on one table and B on the
other.

Join A.F1 to B.F1, A.F2 to B.F2. Set the criteria for a.F3 <>
B.F3

You will still have a problem with your two instances of 1-2-4,
which you can resolve by adding a criteria on the primary key
(which you have not shown) being different.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #2
Thanks Bob!
Just the job. Adding a DISTINCT got rid of the other duplicates. The
code is as below for reference:

SELECT DISTINCT A.F1, A.F2, A.F3
FROM table1 AS A INNER JOIN table2 AS B ON (A.F1 = B.F2) AND (A.F2 =
B.F2)
WHERE (((A.F3)<>b.F3));

regards

Nov 13 '05 #3

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

Similar topics

1
by: Brian | last post by:
I'm trying to find a way to search multiple tables for the same record. Say I have 3 tables all with a name column, I need to search all 3 tables and find matching names. Is there an easy way to...
1
by: Jameel | last post by:
how do i find duplicate records in ASP.net/ADO.net , i know how to do it in classic asp, anything appreciated code,tutorial links etc.. (if rs.eof then add record else error message end if )
2
by: Carroll | last post by:
I'm looking for a way in SQL to find duplicate records in a single table, that are the same based on 3 columns, regardless of what is in the other columns in the duplicate records. I would like to...
1
by: rgurganus | last post by:
I'm trying to setup a way to find possible duplicate or near-duplicate records of contact people. I have a table of 50k records doing an inner join with itself, something like this: SELECT...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
5
by: Sheol | last post by:
Hello everyone! Can somebody please help me with this... I have a VB program that inputs Name and Address. I've made a database in MS Access using ADO Control: Table Name: Contacts Fields are:...
4
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but,...
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
1
by: anantha raman | last post by:
Hai, I am a beginer in Developing ASP.NET webpage. I want to restrict duplicates while uploading the excel data and to inform the user that the perticular cell in excel contains duplicate value...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.