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 from within an
SQL query - leaving one of the records behind of course.
I have a mailing list comprised of a union query that gets records from
two separate tables.
I want to be able to run a query that removes one (or more) of the
duplicated addresses within the query but doesn't make any
modifications to the table.
Please help! :) 16 4149
It doesn't really make sense to say you want to delete duplicate addresses
from a query without modifying a table. A query is just a way of displaying
what's in a table, so anything you delete via a query is deleted from the
table. If you want you could put the results of your unioin query into a new
table (make it a make table query), and then you could remove duplicates
from that table (via a query) without modifying the original tables.
hope that helped
-John
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... 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 from within an SQL query - leaving one of the records behind of course.
I have a mailing list comprised of a union query that gets records from two separate tables. I want to be able to run a query that removes one (or more) of the duplicated addresses within the query but doesn't make any modifications to the table.
Please help! :)
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... 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 from within an SQL query - leaving one of the records behind of course.
I have a mailing list comprised of a union query that gets records from two separate tables. I want to be able to run a query that removes one (or more) of the duplicated addresses within the query but doesn't make any modifications to the table.
Please help! :)
I'm not completely clear on what you are trying to do, but.. A UNION query
will, by default, eliminate duplicate records between the member queries.
If you wanted to include all records, regardless of duplicates, you would
need to use UNION ALL.
If you are getting duplicates from within the member queries, then what you
need is the DISTINCT qualifier.
SELECT DISTINCT
field1, field2, field3
FROM
table1
UNION
SELECT DISTINCT
field1, field2, field3
FROM
table2
This syntax should eliminate all of the duplicates from you query output.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Thank you for your replies.... let me try to explain what I'm doing and
maybe that will help me get the best of your expert advice.
For example: Lets say I have two tables with names, addresses, etc:
Personal table
Work table
I've got a Union query that merges the fields from Personal and Work
together into one mailing list.
However, there are people who belong on both the personal and work
lists - but I don't want to send mail to those individuals twice.
If each field in these records were exactly the same, then select
distinct would work beautifully. Problem is, the dups might be like
this:
FirstName | LastName | HomeNum | HomeStreet
---------------------------------------------
Jonah | Smith | 1983 | Dovecrest Lane (from work)
Jon | Smith | 1983 | Dovecrest (from personal)
So I would like to have a query that would deselect one of those lines
based on the LastName and HomeNum fields matching up. AND, if
possible, I'd like for the line that is kept to come from the Work
table as that is updated more often.
Is the combination of LastName and HomeNum the criteria that would always
use to determine if the records were duplicates?
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Thank you for your replies.... let me try to explain what I'm doing and maybe that will help me get the best of your expert advice.
For example: Lets say I have two tables with names, addresses, etc: Personal table Work table
I've got a Union query that merges the fields from Personal and Work together into one mailing list.
However, there are people who belong on both the personal and work lists - but I don't want to send mail to those individuals twice.
If each field in these records were exactly the same, then select distinct would work beautifully. Problem is, the dups might be like this:
FirstName | LastName | HomeNum | HomeStreet --------------------------------------------- Jonah | Smith | 1983 | Dovecrest Lane (from work) Jon | Smith | 1983 | Dovecrest (from personal)
So I would like to have a query that would deselect one of those lines based on the LastName and HomeNum fields matching up. AND, if possible, I'd like for the line that is kept to come from the Work table as that is updated more often.
I don't know what you mean by "In this case". It would be rather easy to
create a query that would do what you are asking for if that were the
criteria.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... In this case, yes.
Note to all: This message has been posted to at least one other newsgroup.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... 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 from within an SQL query - leaving one of the records behind of course.
I have a mailing list comprised of a union query that gets records from two separate tables. I want to be able to run a query that removes one (or more) of the duplicated addresses within the query but doesn't make any modifications to the table.
Please help! :)
Randy,
I meant yes -- I said "in this case" as I might want to change the
criteria at some point.
I apologize if I have broken etiquette on that - I posted to both
groups as I was not sure which one was the best one to get an answer --
clearly it is this one.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com... I apologize if I have broken etiquette on that - I posted to both groups as I was not sure which one was the best one to get an answer -- clearly it is this one.
Both groups are excellent for getting answers. Many people monitor them both
(and others as well). It can be irritating to spend time posting an answer
only to find later that it had already been answered in another ng.
Multiposting is generally considered poor netiquette. Much less
objectionable is crossposting, that is posting the same message to 2 or 3
groups in a single message. That way if someone answers in one group, the
answer will appear in the others.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Again my apologies - I'll do it the right way next time.
OK, how 'bout this?
SELECT
FirstName,
LastName,
HomeNum,
HomeStreet
From
Table1
UNION
SELECT
FirstName,
LastName,
HomeNum,
HomeStreet
From
Table2
Where
LastName & HomeNum Not IN (
SELECT
LastName & HomeNum
From
Table1)
This should return a list inclusive of both tables but where LastName and
HomeNum are duplicated, only the choice from the first table. I generally
try to avoid using NOT In because it tends to be slow and inefficient, but
there are occasions.
HTH,
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Randy,
I meant yes -- I said "in this case" as I might want to change the criteria at some point.
I believe that did it!!!! Thank you!!!!
On 15 Dec 2005 15:12:52 -0800, "tyrfboard" <ht*****@gmail.com> wrote: I believe that did it!!!! Thank you!!!!
If Brad Johnson, who lives at 123 Sycamore is in your work table and
Jane Johnson, who lives at 123 Honeysuckle is in your person table I
hope you don't want to see Jane in the results of your query.
In case I'm being too obtuse, let me put it differently:
You should not have two tables. You should have one table and an
extra field, which would be used to indicate whether the name is
personal, work or both. Really.
mike
FWIW - Mike is absolutely right. I gave you a workaround but it doesn't
correct the real problem.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"tyrfboard" <ht*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... I believe that did it!!!! Thank you!!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rad |
last post by:
I have a table . It has a nullable column called AccountNumber, which
is of varchar type. The AccountNumber is alpha-numeric. I want to take
data from this table and process it for my application....
|
by: Drew |
last post by:
I have a permission tracking app that I am working on, and I have made the
insert page for it. I am having issues on how to prevent duplicates from
getting entered.
Currently the interface for...
|
by: En |
last post by:
Any ideas what to do for the best?
I have a table that records some transaction data. Each entry in the table
has an auto gen primary key / ID.
Somewhere along the way there are 1000's of...
|
by: Tom Mitchell |
last post by:
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:
...
|
by: makthar |
last post by:
In your query use DISTINCT
SELECT DISTINCT CITY FROM <tablename> WHERE STATE='<state
name>'. This will bring only one of each city from the
table.
>-----Original Message-----
>I'm getting a...
|
by: sjlung |
last post by:
I apologise if this is a trivial question but I have appended three
tables in access and within this table, there are duplicate entries. I
have tried to set my reference number for this table to be...
|
by: tcfin |
last post by:
Hi,
i have a problem to make a transtype
from field XX varchar(20), example :
19 200 340,56
to field YY integer, required :
19200340
|
by: tom.hepworth |
last post by:
Hi
I have a problem which I hope someone can help me with because I
really don't even know where to start with it.
I am using Access 2003. I have a delimited text file which contains
about...
|
by: ARC |
last post by:
Hello all,
So I'm knee deep in this import utility program, and am coming up with all
sorts of "gotcha's!".
1st off. On a "Find Duplicates Query", does anyone have a good solution for...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
| | |