Этот запрос MySQL не выполняется, и я просто не могу понять, почему. Любая помощь приветствуется, и если вам нужна дополнительная информация, пожалуйста, дайте мне знать.
НОВЫЙ ЗАПРОС и НОВАЯ ОШИБКА
select *
from
(select
classId as `Class ID`, mjla_db.StudentRecordTable2.studentId as `Student ID`, quizId as `Quiz ID`, quizGrade as `Quiz Grade`, mjla_db.StudentTable2.lastName, mjla_db.StudentTable2.firstName
from mjla_db.StudentRecordTable2, mjla_db.StudentTable2
where (mjla_db.StudentRecordTable2.studentId=mjla_db.StudentTable2.studentId))
as A
where classId
in (select mjla_db.ClassTable2.classId
from mjla_db.ClassTable2
where mjla_db.ClassTable2.teacherId='T1');
ERROR 1054 (42S22): Unknown column 'classId' in 'IN/ALL/ANY subquery'
select *
from
(select
classId as 'Class ID',
studentId as 'Student ID',
quizId as 'Quiz ID',
quizGrade as 'Quiz Grade',
mjla_db.StudentTable2.lastName,
mjla_db.StudentTable2.firstName
from
mjla_db.StudentRecordTable2,
mjla_db.StudentTable2
where
(mjla_db.StudentRecordTable2.studentId = mjla_db.StudentTable2.studentId)
) as A
where
A.classId in
(select
mjla_db.ClassTable2.classId
from
mjla_db.ClassTable2
where
mjla_db.ClassTable2.teacherId='T1'
);
describe StudentRecordTable2;
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| classId | varchar(20) | NO | MUL | NULL | |
| studentId | varchar(20) | NO | MUL | NULL | |
| quizGrade | tinyint(4) | YES | | NULL | |
| quizId | int(11) | NO | MUL | NULL | |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
describe ClassTable2;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| classId | varchar(20) | NO | PRI | NULL | |
| className | varchar(10) | NO | | NULL | |
| classSection | varchar(5) | NO | | NULL | |
| classSemester | varchar(2) | NO | | NULL | |
| classYear | varchar(4) | NO | | NULL | |
| teacherId | varchar(20) | NO | | NULL | |
+---------------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
describe StudentTable2;
+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| studentId | varchar(20) | NO | PRI | NULL | |
| lastName | varchar(45) | NO | | NULL | |
| firstName | varchar(45) | NO | | NULL | |
| studentPassword | varchar(32) | NO | | NULL | |
+-----------------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)