| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1749 人关注过本帖
标题:一道简单的SQL,求高手
取消只看楼主 加入收藏
accpfriend
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:167
专家分:102
注 册:2006-12-31
结帖率:0
收藏
 问题点数:0 回复次数:2 
一道简单的SQL,求高手
if object_id('S') is not null
drop table S
go
create table S(S# nvarchar(50),SN nvarchar(100),SD nvarchar(100),SA int)
insert S select 'V001',N'小明',N'第二班',25
union all select 'V002',N'小日',N'第三班',28
union all select 'V003',N'小月',N'第一班',26
union all select 'V004',N'小萌',N'第四班',21
union all select 'V005',N'小a',N'第a班',21
go
if object_id('C') is not null
drop table C
go
create table C(C# nvarchar(50),CN nvarchar(100))
insert C select 'C001',N'英语课'
union all select 'C002',N'数学课'
union all select 'C003',N'税收基础'
union all select 'C004',N'化学课'
go
if object_id('SC') is not null
drop table SC
go
create table SC(S# nvarchar(50),C# nvarchar(50),G int)
insert SC select 'V001','C002',95
union all select 'V002','C004',45
union all select 'V001','C003',84
union all select 'V003','C002',65
union all select 'V003','C001',75
union all select 'V004','C001',55
union all select 'V004','C002',55
union all select 'V004','C003',55
union all select 'V004','C004',55
go
select * from S
select * from C
select * from SC

--查询选修全部课程的学员姓名和所属单位

\我也想了很久,但就是不知道如何下手,高手能把你做这道的是如何想,简单给我说一说,主要是做题的思路,
搜索更多相关主题的帖子: SQL 
2007-01-30 16:28
accpfriend
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:167
专家分:102
注 册:2006-12-31
收藏
得分:0 
OK
2007-01-30 16:36
accpfriend
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:167
专家分:102
注 册:2006-12-31
收藏
得分:0 
select * from S where not exists
(
select * from SC where NOT EXISTS
(
select * from C where S#=S.S# AND C#=SC.C#
)
)
不对呀,我照样做,结果不对,而且这种方法有点晕
不太明白
给我正确答案
2007-01-30 16:41
快速回复:一道简单的SQL,求高手
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014157 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved