试一下select xh from cj as c1 where not exists(
select * from cj as c2 where c2.xh='002' and not exists (
select * from c1,c2 where c1.xh=c2.xh ))
select * from cj as c2 where c2.xh='002' and not exists (
select * from c1,c2 where c1.xh=c2.xh ))
解决方案 »
- SQL2008数据库从一台电脑上备份后拷配到另一台电脑上数据库不能还原成功!
- 超级复杂的问题,一个复杂的查询..........各位大哥,救救兄弟啊.
- 十万火急,我更新一个表,where语句写错。更新错。如何恢复啊!!
- 存储过程中的赋值问题
- 如何判断一个字符串,如果全部是数字,则返回该数值,如果有其它字符,返回0。有这样的函数么?
- 临时表插入重复键?
- sql2005与jdbc链接的问题
- 删除sql2000某个数据库的某个用户为什么不可以阿?
- 在Sql server中,如何设定在某一时刻备份数据库中的数据或进行其他操作?
- 在设计取多表字段的DW时,是在选数据源时选多表好呢,还是在sql server中先做好视图好?
- 几天一开机,出现连接不上的问题,不知道怎么回事
- 把一个库backup以后,如何追加到另一个机器的库中去?
select * from cj as c2 where c2.xh='002' and not exists (
select * from c1,c2 where c1.kch=c2.kch ))上面吧学号跟课程号搞错了
select xh from cj where xh <>'001' and kch in (select kch from cj where xh='002') group by xh having sum(1)>=(select sum(1) from cj where xh ='002')
为什么xh<>'001'呢?
上面显示cj的记录只是为了说明cj的结构。其实里面内容可以改动。改动后该语句应该还可通用才对。