Reputation: 213
Below is the table in database:
Product Type1 Type2 Type3 Manufacturer
Notebook 50 Pages 100 Pages 150 Pages KP Mills
Pen Blue Black Red Parker
What should be the SQL Query to display the result in following format:
Product Type Manufacturer
Notebook 50 Pages KP Mills
Notebook 100 Pages KP Mills
Notebook 150 Pages KP Mills
Pen Blue Parker
Pen Black Parker
Pen Red Parker
Upvotes: 1
Views: 62
Reputation:
select product,
type1 as type,
manufacturer
from the_table
union all
select product,
type2,
manufacturer
from the_table
union all
select product,
type3,
manufacturer
from the_table
order by product, type;
Upvotes: 3