Solved

numerous varchar columns in one row

Posted on 2012-12-27
3
195 Views
Last Modified: 2013-01-12
table has email1 email2 email3
varchar

I want to select the row (name,phoneNumber) for each email
0
Comment
Question by:rgb192
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
mcsween earned 500 total points
ID: 38724303
Let's see if I understand.  You have a table like this:
Name, PhoneNumber, Email1, Email2, Email3

Open in new window

and you want it to return like this?:
Bob,555-1212,bob@mail.com
Bob,555-1212,bob@gmail.com
Bob,555-1212,bob@yahoo.com

Open in new window

That would look like this:

SELECT name,phoneNumber,email1
UNION ALL
SELECT name,phoneNumber,email2
UNION ALL
SELECT name,phoneNumber,email3
FROM sometable
WHERE name = 'Bob'

Open in new window

0
 

Author Comment

by:rgb192
ID: 38730361
SELECT first_name,email1
UNION ALL
SELECT first_name,email2
UNION ALL
SELECT first_name,email3
FROM family

Error Code: 1054. Unknown column 'first_name' in 'field list'
0
 

Author Closing Comment

by:rgb192
ID: 38771005
this answer is close to the question
because I think a union would work


thank you
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question