问个新手问题??(无法绑定由多个部分组成的标识符)急救

chp845 2010-05-13 10:02:31
在sql sever 2005中建立三张表:scores表sn,cn,grade(sn,cn为主键),
查询至少选修了学号为028007501学生选修的全部课程的学生的学号:

select distinct sn from scores x
where not exists (select * from scores y where y.sn='4807501')and
not exists(select * from scores z where z.sn=x.sn and z.cn=scores.cn)


怎么提示:消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "y.cn"。
如何解决呀,这是教科书中实例,怎么出错了呀,哪位高手教下呀....
...全文
121 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chp845 2010-05-14
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 dawugui 的回复:]

引用 6 楼 chp845 的回复:
select distinct sn from scores x
where not exists (select * from scores y where y.sn='4807501'and
not exists(select * from scores z where z.sn=x.sn and z.cn=scores.cn))

应该是这样……
[/Quote]
唉,总是看错呀,郁闷着呢........
dawugui 2010-05-13
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 chp845 的回复:]
select distinct sn from scores x
where not exists (select * from scores y where y.sn='4807501'and
not exists(select * from scores z where z.sn=x.sn and z.cn=scores.cn))

应该是这样,我一不小心把')'写到了前面[/Quote]


原来如此.恭喜.
chp845 2010-05-13
  • 打赏
  • 举报
回复
select distinct sn from scores x
where not exists (select * from scores y where y.sn='4807501'and
not exists(select * from scores z where z.sn=x.sn and z.cn=scores.cn))

应该是这样,我一不小心把')'写到了前面
永生天地 2010-05-13
  • 打赏
  • 举报
回复
严重看不懂
sql_lover 2010-05-13
  • 打赏
  • 举报
回复
select distinct x.sn from scores y left scores x
on y.sn='4807501' and x.cn=y.cn
where x.cn is not null
htl258_Tony 2010-05-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 chp845 的回复:]
发现了,自己写错了,那样根本就y.cn无法确定,各位接分把,郁闷总是自己看错了呀....
[/Quote]GX,刚路过
chp845 2010-05-13
  • 打赏
  • 举报
回复
发现了,自己写错了,那样根本就y.cn无法确定,各位接分把,郁闷总是自己看错了呀....
sql_lover 2010-05-13
  • 打赏
  • 举报
回复
你的语句很诡异 看不明白

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧