我寫的查詢在什麼應該是標準的SQL,並在MySQL測試它們。錯誤PostgreSQL中
現在,當我嘗試在PostgreSQL可以運行在他們我得到的所有類型的錯誤,我真的不明白。 這裏的原始查詢,在MySQL的工作:
CREATE VIEW popularCSsections AS (
SELECT sect.csid, COUNT(sc.sid) as numStudents
FROM courseSection sect, studentCourse sc, department d
WHERE sect.csid = sc.csid
AND sect.dcode = d.dcode
AND dname = "Computer Science"
GROUP BY sect.csid
HAVING numStudents > 2
);
給出了這樣的錯誤:
psql:a2tables:60: ERROR: column "Computer Science" does not exist
LINE 8: AND department.dname = "Computer Science"
^
能否請你幫我理解錯誤的性質和幫助我解決這些問題?
其他問題:
CREATE VIEW popularCSsections AS (
SELECT sect.csid, COUNT(sc.sid) as numStudents
FROM courseSection sect, studentCourse sc, department d
WHERE sect.csid = sc.csid
AND sect.dcode = d.dcode
AND dname = 'Computer Science'
GROUP BY sect.csid
HAVING numStudents > 2
);
錯誤:
psql:a2tables:70: ERROR: column "numstudents" does not exist
LINE 8: HAVING numStudents > 2
^
在標準SQL中,字符串使用單引號「''引用,而不是雙引號'」'試試:'AND department.dname ='Computer Science'' – Lee
「Standard SQL」。Ha。* gigglesnort *可悲的是,標準的SQL不是特別輕便,便攜SQL並不總是標準的SQL:S –