Select * from a inner join c
 on a.col=c.col
where not exists(select * from b where b.col=a.col)

解决方案 »

  1.   

    declare @mystr varchar(1000)
    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
      

  2.   

    修改:
    测试环境
    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
      

  3.   

    select distinct a.col from d,a,c where charindex(a.col,c.col)>0 and  not charindex(a.col,d.b.col)>0
      

  4.   

    select a.*
      from a inner join c on a.col=c.col
      where a.col not in (select col from b group by col)
      

  5.   

    select distinct a.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+'%')