Solved

numerous varchar columns in one row

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

11 Experts available now in Live!

Get 1:1 Help Now