0

I have the following data in one query: (there will always be 3 rows of contact data. Always)

name     phone
john     5551234
jane     3452345
paul     8475739

I have the following data in another query:

col1     col2     col3
data1    data2    data3

What I want to do is to add the first query to the second to obtain this:

col1    col2    col3    name1   phone1    name2   phone2    name3   phone3
data1   data2   data3   john    5551234   jane    3452345   paul    8475739
NaN
  • 1,286
  • 2
  • 16
  • 29

1 Answers1

1

Your goal is to create pivot table from your query - and here is a common solution for that in MySQL.

But it's very unstable - much better to do proper formatting in your application since count of specific rows could be various, data could become inconsistent, e t.c. - so in general, this idea is not a good one.

Community
  • 1
  • 1
Alma Do
  • 37,009
  • 9
  • 76
  • 105
  • Thanks Alma. I'm currently doing the formatting in the application code now but that is proving to be unstable as well. Sometimes I get the correct results and sometimes I don't. I thought I'd try to keep it all in a single query and see if that helped. – NaN Oct 17 '13 at 08:05