In the below query i am selecting the values from the table it has 4 columns name,age,class,rollno.And i want to display it in 2 columns (ie)to make 2 column value to move to next row and 4 column value to next row.Pls help me to do this.
StudentID|name/age|class/Roll no|
1 xxx 2
1 5 123556
2 yyy 2
2 5 123557
Select studentid,name.age,class,roll no from student
You can UNION ALL
and use 2 queries. I had to cast the age as a varchar so that it could go in the name.age column
select id, name as 'name.age', class as 'class.rollno'
from student
union all
select id, cast(age as varchar), rollno
from student
order by id, name desc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.