0

This is the current form of data in mysql database:-

| Roll No  | Semester | Sub_code | Sub_name | Sub_grade |
| -------- | -------- |--------- |----------|-----------|
| 19hhh01  | 1        |BSL 001   |    AI    |    B+     |
| 19hhh01  | 1        |CSL 2022  |    OS    |    C+     |
| 19hhh01  | 2        |IUJ 1022  |    DDS   |    A+     |
| 19hhh01  | 2        |KSJ 2012  |    KJ    |    C+     |
| 19hhh02  | 1        |BSL 001   |    AI    |    B+     |
| 19hhh02  | 1        |CSL 2022  |    OS    |    A+     |
| 19hhh02  | 2        |IUJ 1022  |    DDS   |    A+     |
| 19hhh02  | 2        |KSJ 2012  |    KJ    |    A+     |

This is what I actually want in output:-

Roll No Semester Sub_code1 Sub_name1 Sub_grade1 Sub_code2 Sub_name2 Sub_grade2
19hhh01 1 BSL 001 AI B+ CSL 2022 OS C+
19hhh01 2 IUJ 1022 DDS A+ KSJ 2012 KJ C+
19hhh02 1 BSL 001 AI B+ CSL 2022 OS A+
19hhh02 2 IUJ 1022 DDS A+ KSJ 2012 KJ A+

Kindly help me how can I achieve this using mysql query. Thanks.

Someone marked below answer as duplicate to my question but my query is different.

+-----------------+------------+
| id | fieldname  | fieldvalue |
+-----------------+------------+
|  1 | size       | S          |
|  1 | height     | 103        |
|  2 | size       | L          |
|  2 | height     | 13         |
|  2 | color      | black      |

Here we have fieldname+id acts unique column for each id. But in my case I dont have unique column like this.

0 Answers0