我为学生日程表打印输出创建了这个连接语句,我是 sql 和 php 的新手,无法弄清楚我做错了什么。如果有人能提供帮助,我将不胜感激。提前致谢...(附注,如果这是一个非常基本的问题,我很抱歉)...
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);
最佳答案
您有一个报价问题。去掉列别名周围的引号并使用标记
$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)";
关于php - MYSQL语句搞不明白是怎么回事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22379331/