$SQL =" SELECT * FROM student ";
$SQL.=" LEFT JOIN class ON student.class_id = class.class_id ";
$SQL.=" LEFT JOIN room ON student.room_id = room.room_id ";
$SQL.=" WHERE (student.class_id = '$class_id' AND student.room_id = '$room_id') AND (stu_id = '".$_GET["stu_id"]."') ";
SELECT * FROM maintable LEFT JOIN student ON maintable.stu_id = student.stu_id LEFT JOIN class ON maintable.class_id = class.class_id LEFT JOIN room ON maintable.room_id = room.room_id WHERE ORDER BY maintable.main_id DESC (maintable.class_id = '1' AND maintable.room_id = '2') AND (maintable.stu_id = '1')