0

I have two columns (A and B) in a table:

column_A      column_B
   10           alb
   13           clk
   22           mbr

I am looking for a solution which would return:

column_A        10      13     22
column_B        alb     clk    mbr

How can I achieve this?

I don't know the number of source rows - it will change dynamically.

Mat
  • 202,337
  • 40
  • 393
  • 406
Andrew
  • 233
  • 1
  • 3
  • 10
  • Do you already know the number of rows of your original table or not? however it seems to me a typical problem that must be solved at application level. – Nicola Cossu Jul 31 '11 at 14:06
  • look on pivot mysql in the site – Haim Evgi Jul 31 '11 at 14:08
  • Take a look even at this old thread: http://stackoverflow.com/questions/5826455/join-two-tables-with-a-1-m-relationship-where-the-second-table-needs-to-be-fla/5826533#5826533 – Nicola Cossu Jul 31 '11 at 14:41

1 Answers1

0

Try the "Pivot tables" section of this web page: http://www.artfulsoftware.com/infotree/queries.php

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
  • In general, thank you very much for your interest. I was looking just for some kind of solution using PIVOT, but, unfortunately, your suggestions were so vague that I did not find any simple indication for my problem. The web is a whole bunch of examples but not for this kind of problem. I solved the problem based on HTML - tables inside table:)) It is not very elegant but may be satisfactory. Once again, thank you very much. – Andrew Jul 31 '11 at 16:16
  • Did you even read the link? What about http://www.artfulsoftware.com/infotree/queries.php#78? Of course the resource was vague; there's not going to be an example on the Internet specifically for you problem. You're suppose to interpret it and apply the solution to your own problem; that's how you learn. – Martin Bean Aug 01 '11 at 09:04