Solved

numerous varchar columns in one row

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now