473,468 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Return unique entries in access

7 New Member
Somehow I need to only return 1 record if there's two or more in the tables. I'm using this to create a mailing list labels so I don't want to print two or more labels for the same person. I want to find duplicate First and Last Name. Like Tim Wolf appears twice. I just need one label for him. But I need to print a label for Tina Wolf, and so on.

Here's my code so far, only reason I have code is cause access did it for me. I couldn't type this out myself. LOL

Expand|Select|Wrap|Line Numbers
  1. SELECT [Customer List].[Last Name], [Customer List].[First Name], [Customer List].Address, [Customer List].City, [Customer List].State, [Customer List].Zip, [Customer List].[Home #], [Customer List].[Work or Cell #], [Customer List].[PMA Cust], [Offsite Service Records].[PMA Cust]
  2. FROM [Customer List] LEFT JOIN [Offsite Service Records] ON [Customer List].ID=[Offsite Service Records].ID
  3. WHERE ((([Customer List].[PMA Cust]) Is Not Null)) OR ((([Offsite Service Records].[PMA Cust]) Is Not Null))
  4. ORDER BY [Customer List].[Last Name];
I tried to type in "GROUP BY [Customer List].[Last Name]" but that didn't work. Then I tried to use SELECT DISTINCT and that didn't work either. Any help would be greatly appreciated.
Feb 22 '08 #1
2 1604
wevans
7 New Member
I ended up creating another query based on that previous query. Then based the labels report on the second query. This did exactly what I wanted to do. If you still got a solution to do it with one query, I would still like to know how to do that. Thank you
Feb 22 '08 #2
NeoPa
32,556 Recognized Expert Moderator MVP
You can do it one of two ways :
One way is to link your table with an INNER JOIN to a subquery which shows just the two fields (1st & last names) and uses the DISTINCT predicate.
The other way is to GROUP the table by those two fields (not just the one as you have it) but this means that you need to use Min() or some other aggregate function to select which value to return for each of the other fields.

There is actually a better way, a way the database systems were designed to use, and that would be to normalise your database. That way querying is much easier and this situation would never even arise.

I'll post a couple of links to reference and you let me know how you'd like to proceed.
Subqueries in SQL.
Normalisation and Table structures
Feb 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: mr_burns | last post by:
hi, i am wanting to count the number of unique rows under a certain column. i want to count how many times a page has been accessed. how i plan to do this is every time a page is accessed, a...
2
by: grist2mill | last post by:
I have a table 'Group2Operation' that stores many to many relations between the 'Group' table and the 'Operation' table (each group is has permission to perform one or more of the available...
1
by: windandwaves | last post by:
Hi Gurus I am trying to make a table with unique entries. Problem is, the entries are upto 1000 characters long. Can I still apply a unique index and how and if so, what field type should I...
3
by: MLH | last post by:
I have a 50-char job name field (text type) in an Access table. The entries into this field will be unique. No two records will house the same job name. I would like an algorithm that would...
5
by: Paulers | last post by:
Hello all, I have a string array with duplicate elements. I need to create a new string array containing only the unique elements. Is there an easy way to do this? I have tried looping through...
1
by: rdraider | last post by:
Hi all, We have an app that uses SQL 2000. I am trying to track when a code field (selcode) is changed on an order which then causes a status field (status) to change. I tried a trigger but...
2
by: jennk | last post by:
i am working in Access 97, our database tables are linked from ODBCsqlsvr (not even sure what that means). i have a table where each record has a unique customer and their order information. there...
1
by: jeff8676 | last post by:
I'm very new at Access, so if this is a lame question I'm sorry. Anyways, I'm trying to make a query that returns unique entries from a table, but when it finds two entries where everything...
1
by: escapersky | last post by:
I have a database that i've been entering and I need to show how many unique entries I have entered prividing the date range. The database includes date, productID, locationID, quantity etc. ...
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:
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...
0
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,...
1
isladogs
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...
0
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.