求一个SQL语句 选课表t(name,course)name(姓名) course(课程名)aa 语文aa 数学bb 英语cc 语文……想得到只选择了某门课程(如:语文)的人,SQL该怎么写?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select name from table where course='语文' --只选择语文select name from t where not exists (select 0 from t where course<>'语文') select name from t a where not exists (select 0 from t b where a.name=b.name and b.course<>'语文') select name from tb where course='语文' and name in (select name from t group by name having count(1)=1) select * from test1 where uname not in(select uname from test1 where course<>'语文') 一定要用子查询吗?select name from tb where course='语文' and name not in (select name from tb where course <>'语文') selectdistinct a.*from tb ajointb b on a.Name=b.Namewhereb.Course='语文' 问个SQL语句 求SQL联合主键怎么了? Sql Agent代理中的作业执行超时 case语句处理 Null 值的问题 sllserSET LOCK_TIMEOUT SQL排程新算法 一段SQL(再现等待,100分) select如何选择数据库中第n条-m条之间的记录 如何将在读取SqlServer的这句Sql语句改成在Access的数据库中亦可使用??? 将sql一张表转成二维表,执行报错,说是有语法问题!!! 求一个SQL语句 关于内联(inner join),外联(left join....)和子查询(in)的问题
select name from t where not exists (select 0 from t where course<>'语文')
select name from tb where course='语文' and name in (select name from t group by name having count(1)=1)
select name from tb where course='语文' and name not in (select name from tb where course <>'语文')
distinct a.*
from
tb a
join
tb b on a.Name=b.Name
where
b.Course='语文'