472,789 Members | 1,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 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 4471
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.