I have a table name examResults and subject like following
IndexNo | AccYear | SujectID | Mark | Grade
01 | 2014 | 12 | 35 | C
01 | 2014 | 13 | 64 | B
02 | 2014 | 12 | 54 | B
Subject Table
SujectID | SubjectNameE | SubjectNameS
12 | English | lkdfjlsd
13 | Buddhist | hkjdfhsd
I want to grab the data as bellow
IndexNo | AccYear | English | Buddhist | Total
01 | 2014 | 35 | C | 64 | B | 99
you may need to use the GROUP_CONCAT
function See this similar question for reference: One table, two column MYSQL query challenge