I am trying to return a table of data based on a sql query on a wordpress db, the end result will be turned into a csv file and then emailed to a list of recipients (csv and email send working, its just the data doesn't look right), use query:
SELECT * FROM table_name
this returns this info
id | c_id | data_id | name | value
159 | 6 | 15 | salutation | MR
160 | 6 | 15 | full-name | blah
161 | 6 | 15 | phone-number | 123456789
162 | 6 | 15 | email | blah@blah.com
171 | 6 | 16 | salutation | MRS
172 | 6 | 16 | full-name | blah
173 | 6 | 16 | phone-number | 9876543210
174 | 6 | 16 | email | blah2@blah.com
What i actually want to return is a table of data that looks like this
data_id | salutation | full-name | phone-number | email
15 | MR | blah | 123456789 | blah@blah.com
16 | MRS | blah | 9876543210 | blah2@blah.com
Is there a query that can do this or is it better to reformat the initial SQL result with php into the structure i need it?
Disclaimer I am a noob when it comes to SQL and have only ever written the most basic of queries.