Connecting Tech Pros Worldwide Forums | Help | Site Map

Query to return same record more than once

Bill Morrison
Guest
 
Posts: n/a
#1: Nov 13 '05
I have a table that holds customer contact information. The table has
three email fields (Email1, Email2, and Email3). So each customer can
have up to 3 contact email addresses.

I need a query that will return the customers name with each of their
email addresses.

ie If customer has 3 email addresses then following is returned:

Bill Morrison Email1
Bill Morrison Email2
Bill Morrison Email3

Hope this makes sense

Thanks

MGFoster
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Query to return same record more than once


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It would be better to put the email addresses in a separate table. This
will Normalize your db. E.g.:

Customers CustEmails
- ----------- ---------------
CustID 1-->m CustID,
<other fields> Email

This way you can have many emails per customer.

The query would be like this:

SELECT C.FirstName & " " & C.LastName, E.Email
FROM Customers As C INNER JOIN CustEmails As E
ON C.CustID = E.CustID
WHERE <criteria>

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQUx1WoechKqOuFEgEQIMxACgj9FpY+U7KVzcsV4ki3QoJh iMwwIAn1h+
ebU4MjL0nKj1efejTVu/lkXo
=bigj
-----END PGP SIGNATURE-----


Bill Morrison wrote:
[color=blue]
> I have a table that holds customer contact information. The table has
> three email fields (Email1, Email2, and Email3). So each customer can
> have up to 3 contact email addresses.
>
> I need a query that will return the customers name with each of their
> email addresses.
>
> ie If customer has 3 email addresses then following is returned:
>
> Bill Morrison Email1
> Bill Morrison Email2
> Bill Morrison Email3[/color]

Closed Thread