sql - 在 PostgreSQL 中使用 WHERE 子句时出现语法错误
问题描述
我正在尝试在 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);
但是我收到以下错误:
错误:“where”处或附近的语法错误
第 3 行:学生加入讲师,其中 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
连接子句的地方。
推荐阅读
- c - 我无法复制 png 图像
- javascript - 如何计算客户,即打字稿中客户的持续时间
- sql - 将具有固定时间戳的 sysdate 插入表列
- python - PCA 中的负特征值
- javascript - 专门从 JavaScript 文件直接加载网页
- google-cloud-platform - 通过gcloud在数据存储模式下使用firestore时创建数据库?
- python - 如何使用新元素打印列表
- ruby-on-rails - 无法通过序列化程序获取关联的模型值
- java - 我想在 jsp 中显示布尔方法以进行电子邮件验证
- python-3.x - python - 如何使用pandas从Python数据框中的列中查找特定值