0

我在 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     
4

2 回答 2

0

COUNT是一个函数,你需要在*

如:

COUNT(*)

于 2013-03-11T20:43:22.927 回答
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
于 2013-03-11T21:33:35.513 回答