Solved

numerous varchar columns in one row

Posted on 2012-12-27
3
194 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

777 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