0

I need to arrange the values from one table with some strange conditions.
My table is:
| ref | value1 | info1 | value2 | info2 | value3 | info3 |
| 9 | 100 | test1 | 220 | test4 | 300 | test7 |
| 3 | 150 | test2 | 250 | test5 | 400 | test8 |
| 7 | 200 | test3 | 290 | test6 | 500 | test9 |

I need to be able to get a result such as:
| ref | values | infos |
| 9 | 100 | test1 |
| 3 | 150 | test2 |
| 7 | 200 | test3 |
| 9 | 220 | test4 |
| 3 | 250 | test5 |
| 7 | 290 | test6 |
| 9 | 300 | test7 |
| 3 | 400 | test8 |
| 7 | 500 | test9 |

I can't even start to understand if what I need is possible and I can't get my head around it. Any help will be most appreciated.

0

1 Answer 1

2

You could use UNION ALL

SELECT ref, value1 as values, info1 as Infos FROM tbl
UNION ALL
SELECT ref, value2 as values, info2 as Infos FROM tbl
UNION ALL
SELECT ref, value3 as values, info3 as Infos FROM tbl
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.