NaN
NaN

Reputation: 1306

How to combine columns into a single row

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

Upvotes: 0

Views: 78

Answers (1)

Alma Do
Alma Do

Reputation: 37365

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.

Upvotes: 1

Related Questions