If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Transform columns into rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-29-10, 19:22
soriaedu79 soriaedu79 is offline
Registered User
 
Join Date: Apr 2010
Posts: 2
Transform columns into rows

Hello,

I´m totally stuck with this problem. I have searched the solution in the forums but the things I saw didn`t work fine.

I have this table:


Code:
ID | Total_time | Partial_time
-----------------------------------------
1         60            30
and I want to transform if in this one:

Code:
ID | Parameter | Value
----------------------------------------
1    Total_time      60
1    Partial_time    30
Any help? I guess that it´s not a difficult solution but I'm not able to find it.

Thank you so much in advance.

Edu[/code]
Reply With Quote
  #2 (permalink)  
Old 04-29-10, 22:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Code:
SELECT id
     , 'Total_time' AS parameter
     , Total_time AS value
  FROM daTable
UNION ALL
SELECT id
     , 'Partial_time'
     , Partial_time 
  FROM daTable
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-30-10, 09:27
soriaedu79 soriaedu79 is offline
Registered User
 
Join Date: Apr 2010
Posts: 2
Thank you so much, if works!!!

Regards
Reply With Quote
Reply

Tags
mysql, transform columns

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On