473,789 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Distinct email addresses in 2 tables with different field names

Hi everyone,

I have 2 tables with table A containing an 'email' field and table B
containing 2 fields 'primaryemail' and 'secondaryemail '. Now is it possible
to issue a query that would return only the unqiue email addresses in these
3 fields? So a long list with no duplicate emails(distinct ).

Thank you
Maz.
Jul 19 '05 #1
2 2787
> I have 2 tables with table A containing an 'email' field and table B
containing 2 fields 'primaryemail' and 'secondaryemail '. Now is it possible
to issue a query that would return only the unqiue email addresses in these
3 fields? So a long list with no duplicate emails(distinct ).


Depends on the version of MySQL you are using. If you are using 4.1
review the manual section on subqueries, particularly this section:

http://www.mysql.com/documentation/m...STS_subqueries

Example: What kind of store is present in all cities?

SELECT DISTINCT store_type FROM Stores S1
WHERE NOT EXISTS (
SELECT * FROM Cities WHERE NOT EXISTS (
SELECT * FROM Cities_Stores
WHERE Cities_Stores.c ity = Cities.city
AND Cities_Stores.s tore_type = Stores.store_ty pe));

If you're not using 4.1, then you won't be able to do it in a single
query. Give more information about the version you are using, and I'll
try to help.

Lukas
Jul 19 '05 #2
> I have 2 tables with table A containing an 'email' field and table B
containing 2 fields 'primaryemail' and 'secondaryemail '. Now is it possible
to issue a query that would return only the unqiue email addresses in these
3 fields? So a long list with no duplicate emails(distinct ).


Depends on the version of MySQL you are using. If you are using 4.1
review the manual section on subqueries, particularly this section:

http://www.mysql.com/documentation/m...STS_subqueries

Example: What kind of store is present in all cities?

SELECT DISTINCT store_type FROM Stores S1
WHERE NOT EXISTS (
SELECT * FROM Cities WHERE NOT EXISTS (
SELECT * FROM Cities_Stores
WHERE Cities_Stores.c ity = Cities.city
AND Cities_Stores.s tore_type = Stores.store_ty pe));

If you're not using 4.1, then you won't be able to do it in a single
query. Give more information about the version you are using, and I'll
try to help.

Lukas
Jul 19 '05 #3

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

Similar topics

9
6150
by: Dave M | last post by:
All I've got a database that keeps track of sales of widgets. Each company that belongs to my organiztion is to report their widget sales or no sales every month. There are several different types of widgets. Not all companies sell or report all types of widgets. We want to report how many companies have reported or not reported their
0
1332
by: Maziar Aflatoun | last post by:
Hi everyone, I have 2 tables with table A containing an 'email' field and table B containing 2 fields 'primaryemail' and 'secondaryemail'. Now is it possible to issue a query that would return only the unqiue email addresses in these 3 fields? So a long list with no duplicate emails(distinct). Thank you Maz.
2
12548
by: mfyahya | last post by:
I have two tables, both containing an 'authors' column. Is there a way to get a unique list of authors from the two tables? I tried SELECT DISTINCT `authors` from `table1`, `table2`; but I got an "Column 'authors' in field list is ambiguous" error. Is there also a query to return only the count of distinct authors from the two tables? Thanks for any help.
1
1303
by: Richard Jenkins | last post by:
Hi, I'm designing a database for a small removal company. The information we need includes the customer's contact address, the address they're moving from and the address they're moving to. I currently have the contact address in the Customers table, the from and to addresses in seperate tables (FromAddresses & ToAddresses) and a Moves table linking the three together.
3
1265
by: kieran | last post by:
Hi, i know this should be easy but cant get it exactly right. i have a Datagrid pulling results from a stored proc in database, it outputs four columns, one of which is an email address column. i am trying to get all the email addresses to be clickable email links using the mailto: scenerio but am having trouble with code as im a newbie.
2
2768
by: Tomdhu | last post by:
I've got a Contacts & Events database in Access 2K where contacts attend various events. At present, where I want to group e-mail all the attendees who are going to attend a particular event, I run a macro which runs a select query which strips out and exports a list of their e-mail addresses ( separated by commas) into a text file. I then copy the CSV e-mail addresses and paste them into the BCC field of Outlook. I'd love to have a...
2
5566
by: tk | last post by:
Hello, At the moment im building a database for a driving school, I have a customer field, with email address as an attribute. I dont know much about macros in access but once the customer has booked a lesson i want a automated email to be sent to the customer 3 days or a few days before their driving lesson, stating the driving instructor, booking ID time and date etc. I have 5 tables apart from customer: Employee, Car, Booking, Package...
8
8098
by: penfold33 | last post by:
Hi I need to generate a CSV of names and address from a table and I would like only one result (it doesn't matter which) per distinct email address. If possible, they also need to be ordered by DateAdded descending so I can select just the most recent 1000 results. My table contains a number of fields such as FirstName, LastName, Address1, Address2, Postcode, Email etc. A plain distinct doesn't work as they may have entered a slightly...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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...
0
9983
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
9020
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...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5417
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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 we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.