在 PostgreSQL 中使用 WHERE 子句时出现语法错误
Syntax error while using WHERE clause in PostgreSQL
我正在尝试 运行 一些与 PostgreSQL 中的大学数据库相关的查询。
为了找到来自不同部门的导师建议的学生,我使用了-
select distinct s_id from advisor
where (s_id ,i_id) in (select distinct student.id,instructor.id from
student join instructor where student.dept_name <> instructor.dept_name);
但是我收到以下错误:
ERROR: syntax error at or near "where"
LINE 3: student join instructor where student.dept_name <>
instructo...
任何修复?
请试试这个:
select distinct s_id from advisor
where (s_id ,i_id) in (select distinct student.id,instructor.id from
student join instructor on student.dept_name <> instructor.dept_name);
而不是你需要使用 on
子句和连接的地方。
我正在尝试 运行 一些与 PostgreSQL 中的大学数据库相关的查询。 为了找到来自不同部门的导师建议的学生,我使用了-
select distinct s_id from advisor
where (s_id ,i_id) in (select distinct student.id,instructor.id from
student join instructor where student.dept_name <> instructor.dept_name);
但是我收到以下错误:
ERROR: syntax error at or near "where"
LINE 3: student join instructor where student.dept_name <> instructo...
任何修复?
请试试这个:
select distinct s_id from advisor
where (s_id ,i_id) in (select distinct student.id,instructor.id from
student join instructor on student.dept_name <> instructor.dept_name);
而不是你需要使用 on
子句和连接的地方。