Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Question Unanswered: Make Rows Columns

    I have a table with 2 Columns and an indefinite number of rows:
    QuestionItemTypeID Question
    99DDB761-703D-4F8A-9859-0F4A7455A135 Backup Training Plan
    C828FAF5-864F-4E9A-A6D4-0FB9F8E744DE System Applications Load
    6CC0EDEB-179C-4F81-ABD6-138CC23FFD32 Which Organization?
    16E0A8D7-5C55-4315-A9DD-1746822F5FCD Is the network cable plugged in?


    I need for each question to become the columns of a new table.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    export this table to a csv file
    import to excel
    write a transpose/pivot routine in excel
    import the resulting table back into mysql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Posts
    3
    Thank you.
    Is there any ways to accomplish it within SQL?


    --> I used a cursor and added the columns dynamically.
    That works. Just hoped for a SQL function...
    Last edited by isabelle; 02-26-08 at 17:33.

  4. #4
    Join Date
    Feb 2008
    Posts
    3
    Standard SQL does not support this.

    Some vendors provide prioprietary pivoting functions that may allowed you to do it, but you will need some kind of pivoting tool.
    Last edited by r937; 02-28-08 at 13:38.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by laddy7690
    Standard SQL does not support this.
    there is no built-in function for it, no, but it is certainly possible to do this with standard sql

    just very very clumsy

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2008
    Posts
    3
    You're right.

    I thought she was importing a file into a table, not querying an existing table.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •