473,287 Members | 3,319 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,287 software developers and data experts.

Find Duplicates Query

All:

I'm stumped on a query. How do I find duplicates in a table where one
of the duplicates has values is a certain field and the other doesn't.

For example, I have the following table:

tblItems
ItemID
ItemLabel
ItemLat
ItemLong
(many other fields)

I want to return all the fields of all the records where there are two
or more identical ItemLabels, but only where ItemLat and ItemLong are
not null in one record and null in the other record(s).

Thanks

Tom
Nov 12 '05 #1
3 4530
1. Open the database window to tables, right click on TblItems and copy.
2. Move the cursor to a blank area, right click and paste. Name the copy
TblItemsLatLongNull.
3. Create a query based on TblItems and set the criteria of ItemLat and
ItemLong to Is Not Null.
4. Create a query based on TblItemsLatLongNull and set the criteria of ItemLat
and ItemLong to Is Null.
5. Create a third query and include both queries in 3 and 4.
6. Join the ItemLabel field in both queries.
7. Run the query.

The join on ItemLabel will cause the query to return all records with duplicate
ItemLabel. Since the first query contains only records where ItemLat and
ItemLong are not null and the second query contains records where they are null,
the third query returns matching records where ItemLat and ItemLong are not null
in at least one of the matching records and null in one or more of the other
matching records.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Tom Mitchell" <rt*****@swbell.net> wrote in message
news:70*************************@posting.google.co m...
All:

I'm stumped on a query. How do I find duplicates in a table where one
of the duplicates has values is a certain field and the other doesn't.

For example, I have the following table:

tblItems
ItemID
ItemLabel
ItemLat
ItemLong
(many other fields)

I want to return all the fields of all the records where there are two
or more identical ItemLabels, but only where ItemLat and ItemLong are
not null in one record and null in the other record(s).

Thanks

Tom

Nov 12 '05 #2
Thanks for the reply, but I don't think this is quite what I want.

Your approach returns duplicate fields - e.g. if there is an ItemColor
field then I will get a TblItems.ItemColor and a
TblItemsLatLongNull.ItemColor in the same record.

What I want is to get two records one with complete data from TblItems
and the other with complete data from TblItemsLatLongNull.

I've had a go at it by making a qryItemsLatLongNotNull and returning
only the ItemLabel, then making another query that links that
ItemLabel back to tblItems.ItemLabel. The problem with that is that I
get records back where the only record is one with no duplicates.

Any other suggestions are gratefully accepted.

Thanks

Tom
"PC Datasheet" <sp**@nospam.spam> wrote in message news:<yU******************@newsread1.news.atl.eart hlink.net>...
1. Open the database window to tables, right click on TblItems and copy.
2. Move the cursor to a blank area, right click and paste. Name the copy
TblItemsLatLongNull.
3. Create a query based on TblItems and set the criteria of ItemLat and
ItemLong to Is Not Null.
4. Create a query based on TblItemsLatLongNull and set the criteria of ItemLat
and ItemLong to Is Null.
5. Create a third query and include both queries in 3 and 4.
6. Join the ItemLabel field in both queries.
7. Run the query.

The join on ItemLabel will cause the query to return all records with duplicate
ItemLabel. Since the first query contains only records where ItemLat and
ItemLong are not null and the second query contains records where they are null,
the third query returns matching records where ItemLat and ItemLong are not null
in at least one of the matching records and null in one or more of the other
matching records.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Tom Mitchell" <rt*****@swbell.net> wrote in message
news:70*************************@posting.google.co m...
All:

I'm stumped on a query. How do I find duplicates in a table where one
of the duplicates has values is a certain field and the other doesn't.

For example, I have the following table:

tblItems
ItemID
ItemLabel
ItemLat
ItemLong
(many other fields)

I want to return all the fields of all the records where there are two
or more identical ItemLabels, but only where ItemLat and ItemLong are
not null in one record and null in the other record(s).

Thanks

Tom

Nov 12 '05 #3
All:

Just to follow-up – I think I have this solved.

I created one query that returns ItemLabel for just those with
non-null Latitudes (qryNoNull). Another query (qryNull) returning
ItemLabel for just those with null Latitudes. A third query
(qryCount) that returns the ItemLabel and a count of the number of
records with that ItemLabel.

A fourth query (qryCountDetail) then joining the results of qryCount
to tblItem (the underlying table) returning all the fields for only
those labels that have a count >=2. And finally a fifth query joining
qryCountDetail to qryNull and qryNoNull on ItemLabel and returning all
the fields in qryCountDetail.

Not very elegant, but it gets the job done.

Thanks - especially to you PCDatasheet for answering the first time
around.

Tom
"Tom Mitchell" <rt*****@swbell.net> wrote in message
news:70*************************@posting.google.co m...
All:

I'm stumped on a query. How do I find duplicates in a table where one
of the duplicates has values is a certain field and the other doesn't.

For example, I have the following table:

tblItems
ItemID
ItemLabel
ItemLat
ItemLong
(many other fields)

I want to return all the fields of all the records where there are two
or more identical ItemLabels, but only where ItemLat and ItemLong are
not null in one record and null in the other record(s).

Thanks

Tom

Nov 12 '05 #4

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

Similar topics

1
by: Phil | last post by:
Hi. There is probably a very simple explanation for this. I am using the find duplicates wizard, I am asked for the fields that may contain duplcate info. So far so good at this point it functions...
1
by: Phil | last post by:
Hi Daryl. Thanks for you interest. I don't have the SQL, unlesss you mean the SQL behind the query? as to the "re-structuring" The first part of the wizard asks for the fields that may contain...
2
by: Phil | last post by:
Hi. I have a table containing primary address, secondary address, road,town, postcode, there are otherfields within the table requestid, round, day, etc. I want to find all instances of the...
3
by: Sim Zacks | last post by:
I am using 8.0 beta 1 on an RH 8 Linux server. I have a union query that I am converting from access (where it worked) and it is returning duplicates. The only difference between the two rows is...
16
by: tyrfboard | last post by:
I've been searching for awhile now on how to remove duplicates from a table within an Access db and have found plenty of articles on finding or deleting duplicates. All I want to do is remove them...
6
by: Parasyke | last post by:
I have a form that uses has a series of about 10 different queries to get the final VIEW query to populate my form. I wrote the below to find the duplicates, which works. I don't want to delete the...
4
by: Killer42 | last post by:
Hi all. Sorry, this is probably a really simple one but I'm having some difficulty with it, and don't have much time to devote to it right now. I need to find all the records which have...
1
by: aknoch | last post by:
My basic situation is this - I ONLY want duplicates, so the opposite of DISTINCT: I have two tables. Ordinarily, Table1ColumnA corresponds in a one to one ratio with Table2ColumnB through a...
9
by: iheartvba | last post by:
To put the below code simply, I have created a find duplicates query for a table using the Access query wizard. I have then tried to plug the Sql String (strSqlDupColl) copied from the Query Builder...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.