Select * from a inner join c
on a.col=c.col
where not exists(select * from b where b.col=a.col)
on a.col=c.col
where not exists(select * from b where b.col=a.col)
解决方案 »
- 在sql server2000中写一个存储过程
- 有关sql2005登陆连接不到服务器的问题
- 在SQL中smalldatetime 什么东西
- MS-SQL2005中输入关键字可以像类似VS2005那样弹出下拉框提示??
- sql问题
- 急救![数据库如何与外部程序联系]~
- 行列转换问题,关注生产进度
- 简单送分题目:在将excel 导入sql server 2000 中遇到的小问题
- 我做了一个很大的视图(外联接了许多表),但速度太慢,在SQL-server中如何优化
- 小弟请问各位大虾,对于VFP中的图形显示问题,是不是设为通用形字段是最好的,另外可否实际图片字段在浏览器中放大显示的问题,谢谢!
- SQL性能的问题
- 急问:一个令人头疼的数据库结构问题!请高手狂入~~
select @mystr='( col not like ''%'+b.col+'%'' and ' from b
set @mystr=substring(@mystr,len(@mystr)-4)+') or '
select @mystr='( col like ''%'+c.col+'%'' or ' from b
set @mystr=substring(@mystr,len(@mystr)-3)+') '
set @mystr='select * from a where '+@mystr
exec @mystr
测试环境
create table #a (col varchar(100))
create table #b (col varchar(100))
create table #c (col varchar(100))
insert into #a values ('abcde')
insert into #a values ('a2bcde')
insert into #a values ('a4bcde')
insert into #a values ('ab5cde')
insert into #b values ('a5')insert into #c values ('a')
insert into #c values ('e')
insert into #c values ('f')
insert into #c values ('z')declare @mystr varchar(1000)
set @mystr=''
select @mystr=@mystr+' col not like ''%'+#b.col+'%'' and ' from #b
set @mystr='('+substring(@mystr,1,len(@mystr)-4)+') or '
select @mystr=@mystr+' col like ''%'+#c.col+'%'' or ' from #c
set @mystr='('+substring(@mystr,1,len(@mystr)-3)+') '
set @mystr='select * from #a where '+@mystr
exec (@mystr)
go drop table #a
drop table #b
drop table #c
from a inner join c on a.col=c.col
where a.col not in (select col from b group by col)
from a
where
a.col not in (select distinct a.col
from a,b
where a.col like '%'+b.col+'%') and
a.col in (select distinct a.col
from a,c
where a.col like '%'+c.col+'%')