By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

How to combine two data rows into one

P: 48
I am trying to find a way to combine two rows of data into one. the data is as follows
Fields: Company Phone
XYZ 801.222.3333
XYZ 712.444.5555
I want to achieve the following result:

Fields: Company Phone1 Phone2
XYZ 801.222.3333 712.444.5555
Jan 6 '12 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,359
Why would you want to do that? You would be denormalizing the data.
Jan 6 '12 #2

P: 48
this data is used for an automated dialer. the way the program is set up. it require the data to be formatted in one row to be mapped correctly. the original table were remain the same. however i would a query that generate the one row per company
Jan 6 '12 #3

Rabbit
Expert Mod 10K+
P: 12,359
And if a company has more than 2 phones?
Jan 6 '12 #4

P: 48
i would like to do the same if the company has more than two phone numbers. if i figure out how to solve the problem with two numbers. I think i might be able to make it work regardless of the number of phone numbers.
Jan 9 '12 #5

Rabbit
Expert Mod 10K+
P: 12,359
First you need to number the rows breaking on the company. Then you pivot your data on that new field. Unfortunately, MySQL doesn't have row number functionality nor does it have pivot syntax. But fortunately, you can achieve a similar result using variables and case statements / self joins.
Jan 9 '12 #6

P: 48
Thanks. I will try that in access and see what i can figure out. I appreciate your help
Jan 9 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.