2014-03-13 1 views
0

학생 일정 출력용으로이 조인문을 만들었습니다. 저는 SQL 및 PHP를 처음 사용하기 때문에 잘못 입력 한 것을 알아낼 수 없습니다. 사람이 내가 크게 .. 미리 감사드립니다 ... 감사하겠습니다 도움이 될 수 있다면MYSQL 문이 잘못 된 것을 알아낼 수 없습니다.

mysql_select_db($database_newconn, $newconn); 
$query_Recordset1 = "SELECT a.student_id AS "Student ID", f.name AS "Course Name", g.name AS "Lesson Name", g.date AS "Lesson Date", g.start_time AS "Lesson Start Time", g.end_time AS "Lesson End Time", CONCAT(h.first_name,' ', h.last_name) AS "Lesson Tutor" FROM student_table a JOIN enrollement_schedule_table b ON(a.id = b.student_id) JOIN course_table f ON(f.id = b.course_id) JOIN student_attendance_slot_table c ON(c.student_id = a.id) JOIN lesson_table g ON(g.id = c.lesson_id) JOIN tutor_table d ON(d.id = g.tutor_id) JOIN staff_table h ON(h.id = d.staff_id)"; 
$Recordset1 = mysql_query($query_Recordset1, $newconn) or die(mysql_error()); 
$row_Recordset1 = mysql_fetch_assoc($Recordset1); 
$totalRows_Recordset1 = mysql_num_rows($Recordset1); 
+6

어떤 오류가 발생합니까? 작동하지 않는 것은 무엇입니까? 이 문제를 해결하기 위해 무엇을 했습니까? –

+0

가능하면 mysql_connect에 연결을 바꾸거나 더 이상 사용되지 않는 mysql_connect 대신 PDO를 사용해야한다. 미안, 여기서 말하는 것이 필수적이다. 그래서 나는 그렇게 할 사람이 될 것이라고 생각했다. – Jack

답변

6

당신은 인용 문제가 ... (p.s을이 정말 기본적인 질문합니다. 내가 미안 해요). 당신의 열 별칭을 사용 주위에 따옴표를 제거하면 다시 사용할 필요가

$query_Recordset1 = " 
    SELECT a.student_id AS `Student ID`, 
     f.name AS `Course Name`, 
     g.name AS `Lesson Name`, 
     g.date AS `Lesson Date`, 
     g.start_time AS `Lesson Start Time`, 
     g.end_time AS `Lesson End Time`, 
     CONCAT(h.first_name,' ', h.last_name) AS `Lesson Tutor` 
     FROM student_table a 
     JOIN enrollement_schedule_table b ON(a.id = b.student_id) 
     JOIN course_table f ON(f.id = b.course_id) 
     JOIN student_attendance_slot_table c ON(c.student_id = a.id) 
     JOIN lesson_table g ON(g.id = c.lesson_id) 
     JOIN tutor_table d ON(d.id = g.tutor_id) 
     JOIN staff_table h ON(h.id = d.staff_id)"; 
+0

감사합니다 완벽하게 작동합니다 ..... – user3415402

0

대신 큰 따옴표의 쿼리의 필드 틱 틱. 이것을 확인하십시오 :

SELECT 
a.student_id AS `Student ID` 
, f.name AS `Course Name` 
, g.name AS `Lesson Name` 
, g.date AS `Lesson Date` 
, g.start_time AS `Lesson Start Time` 
, g.end_time AS `Lesson End Time` 
, CONCAT(h.first_name, ' ', h.last_name) AS `Lesson Tutor` 
FROM 
student_table a 
JOIN enrollement_schedule_table b 
ON (a.id = b.student_id) 
JOIN course_table f 
ON (f.id = b.course_id) 
JOIN student_attendance_slot_table c 
ON (c.student_id = a.id) 
JOIN lesson_table g 
ON (g.id = c.lesson_id) 
JOIN tutor_table d 
ON (d.id = g.tutor_id) 
JOIN staff_table h 
ON (h.id = d.staff_id) ; 
관련 문제