我有四张桌子
1.student-它包含id名称等
2.marks - 它包含markid,student_id,batch,class,section,subject_id,exam_id,obt_mark
3.subject表 - 它包含sub_id,sub_name
4. exam_type- examtype_id,exam_name
我需要批量分类帐-2014,class = 5,section = 1,exam_id = 3,如下所示 -
NAME ROLL NO SUB1 SUB2 SUB3 TOTAL RESULT POSITION RANK RAM 0054 65 54 64 183 PASS FIRST 2 HAri 0054 65 54 65 184 PASS FIRST 1 gopal 0054 65 50 65 180 PASS FIRST 3 saroj 0054 65 44 65 174 PASS FIRST 4
提前致谢。
这里我有sql查询
SELECT `marklists`.`mrk_sub_id1`, `marklists`.`mrk_marks`, `marklists`.`mrk_practical`, `marklists`.`mrk_exam_type`, `students`.`id` as st_id, `students`.`st_roll`, `students`.`st_name`, `students`.`batch`, `students`.`st_class`, `students`.`st_section`, `courses`.`id`, `classes`.`class_name` as class_name, `courses`.`sb_name` as subject_name, `courses`.`sb_fullmark` as full_marks, `courses`.`sb_passmark` as pass_marks FROM (`marklists`) LEFT JOIN `classes` ON `marklists`.`mrk_class` = `classes`.`id` LEFT JOIN `students` ON `marklists`.`mrk_student_id`=`students`.`id` LEFT JOIN `courses` ON `marklists`.`mrk_sub_id`=`courses`.`id` WHERE `marklists`.`mrk_exam_type` = '3' AND `marklists`.`mrk_batch` = '3' AND `marklists`.`mrk_class` = '1' AND `marklists`.`mrk_section` = '1'
我需要上面的分类帐任何帮助??
答案 0 :(得分:0)
根据公共密钥和您需要的标题加入表格,您可以使用pivot运算符将行转换为列,并使用where子句表示其余条件 希望这有帮助。