0

I have a query in mysql which returns the following:

Amount1    Amount2    Amount3    
    0.1        0.3        0.6

I need the data in the following format:

Amount1   0.1
Amount2   0.3
Amount3   0.6

The query always return a single row with three columns. How can I change the format?

Thanks

user3245747
  • 805
  • 2
  • 17
  • 30

1 Answers1

1

Your only option is to select each column per query and union them all.

Example:

select 'Amount1' as amount_type, `Amount1` as amount_value from your_query_results
union all
select 'Amount2', `Amount2` from your_query_results
union all
select 'Amount3', `Amount3` from your_query_results
Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82