请帮我修改一下上面代码运行报这个SQL 错误 [10250] [42000]: Error while compiling statement: FAILED: SemanticException [Error 10250]: Line 1:55 Invalid SubQuery expression 'c_id': For Exists/Not Exists operator SubQuery must be Correlated.
时间: 2024-02-06 09:02:04 浏览: 175
SQL错误状态的提示信息
根据错误提示,需要将第三个子查询改为关联子查询,即将s1.s_id=s3.s_id改为s2.s_id=s3.s_id,同时在查询语句中给子查询加上别名,如下所示:
```
SELECT *
FROM score s1
WHERE NOT EXISTS (
SELECT *
FROM score s2
WHERE s2.s_id = 1
AND NOT EXISTS (
SELECT *
FROM score s3
WHERE s2.s_id = s3.s_id
AND s2.c_id = s3.c_id
AND s1.s_id = s3.s_id
)
);
```
这样就可以解决SQL语法错误了。
阅读全文