Get columns from query

Is it possible to get a list of columns from a query?

I have a table:-
SQL Table
But I want it to display the contents as:-
2
I know I could use a query such as:-
Select DISTINCT `question` FROM `myTable` WHERE `surveyID` = 1; 

Open in new window


Then build up the SQL statement to display my table.

I was going to use SQLite but think its not powerful enough to do this, so was thinking of using MySQL.

Any ideas if this is even possible, and if possible how can I do it?

Thank you
tonelm54Asked:
Who is Participating?
 
Tomas Helgi JohannssonCommented:
Hi!

You could use some sort of pivot query here.
Look at this example
http://www.boynux.com/creating-pivot-reports-in-mysql/
and here
http://www.artfulsoftware.com/infotree/qrytip.php?id=78

Regards,
     Tomas Helgi
0
 
tonelm54Author Commented:
Need to put it in a query from a database, not as a pivot table
0
 
Tomas Helgi JohannssonCommented:
Hi!

If you look at the examples then you will see how this pivot query (executed inside the database)
transforms your data in pivot like manner into the format you are asking for.

Regards,
   Tomas Helgi
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.