我为学生时间表打印输出创建了这个连接语句,我是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);
答案 0 :(得分:6)
您有引用问题。删除列别名周围的引号并使用刻度
$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)";
答案 1 :(得分: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) ;