473,788 Members | 2,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing duplicates from query, but not from table

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! :)

Dec 15 '05
16 4187
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.

Dec 15 '05 #11

"tyrfboard" <ht*****@gmail. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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.

Dec 15 '05 #12
Again my apologies - I'll do it the right way next time.

Dec 15 '05 #13
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.goo glegroups.com.. .
Randy,

I meant yes -- I said "in this case" as I might want to change the
criteria at some point.


Dec 15 '05 #14
I believe that did it!!!! Thank you!!!!

Dec 15 '05 #15
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

Dec 16 '05 #16
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.goo glegroups.com.. .
I believe that did it!!!! Thank you!!!!


Dec 16 '05 #17

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

Similar topics

3
17946
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. Before doing that I would like to filter out duplicate AccountNumbers. I get most of the duplicates filtered out by using this query: select * from customers where AccountNumber NOT IN (select AccountNumber from customers where AccountNumber...
4
3627
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 the app has a mixture of select boxes, list boxes and checkboxes. The form submits the page to processAIMR.asp and then does the inserting. I am using a loop to insert a new record for each checkbox checked or listbox entry selected. My...
2
1486
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 duplicate transactions been entered, however they are unique because they have different primary key / ID. Does anyone know the best way to remove the duplicates from the table but
3
4612
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: tblItems ItemID ItemLabel
0
2585
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 list of addresses from a database and binding them to a >datagrid. I have a dropdown list that allows the user
2
2687
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 a primary key to ensure duplicates are no longer shown but this changes itself as soon as the tables are all appended together. I appreciate any help you can give me. Thanks alot.
4
6323
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
5
2014
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 200,000 lines. There are only 2 fields, Role and ID. The role field contains many duplicates, out of the 200,000 records I think there are only 16,000 unique roles. Role ID AB_F2S_COST_PLAN_CLK EE1
16
3520
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10175
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.