答案 0 :(得分:0)
感谢大家,通过左联接解决了问题。
SELECT
sm.`student_id`, sm.`subject_id`, s.`name` AS subject_name, sm.`marks_obtained` AS e_11 , e2.`marks_obtained` AS e_14
FROM
ims_studentmarks sm INNER JOIN ims_subject s ON s.`id` = sm.`subject_id`
LEFT JOIN ims_studentmarks e2 ON e2.`subject_id` = sm.`subject_id` AND e2.`student_id` = sm.`student_id` AND e2.`exam_id` = 14
WHERE sm.`exam_id` = 11
AND sm.student_id IN (1789)
答案 1 :(得分:0)
要将行(行)转换为列,请使用以下代码:
SELECT my_column_id,GROUP_CONCAT(my_column_name)
FROM my_table
GROUP BY my_column_id as All_Columns_Name_Asign_to_Column_id