我一直在SQLite中收到此错误:
查询错误:靠近“FROM”:语法错误无法执行语句
SELECT Name, CourseId
FROM Lecturer JOIN Lecture ON Lecturer.LecturerId = Lecture.LecturerId
JOIN (SELECT CourseId
FROM Course
WHERE EXISTS (SELECT *
FROM Exam
WHERE Exam.CourseId = Course.CourseId
AND (SELECT COUNT *
FROM Exam
WHERE Grade > 6)
<
(SELECT COUNT *
FROM Exam
WHERE Grade < 6)))
USING Course.Id
答案 0 :(得分:0)
COUNT
是一个函数,您需要围绕*
如:
COUNT(*)
答案 1 :(得分:0)
我通常会为内联视图指定一个别名,例如FOO,并使用on ...子句将外部表连接到内联视图:
select * from x
join
(
select someColumn, someOtherColumn...
) as FOO
on x.somecolumn = FOO.somecolumn
我会这样做:
select lecture.*, FOO.courseid
from lecture
join lecturer on lecture.lecturerid = lecturer.lecturerid
join
(
you inline view selecting the courses
) as FOO
on lecture.courseid = FOO.courseid