不知道是不是这个意思:
select * from SYS where CallID like '%'+isnull((select distinct CallerID from SBS),'')+'%'

解决方案 »

  1.   


    楼主你的sys.callid能够和sbs.callerid
    这两个字符,是怎么个匹配方式呢?
      

  2.   

    试试:
    select * from SYS a,(select distinct CallerID from SBS) b where cast(a.CallID as varchar like  '%'+b.CallerID +'%'
      

  3.   

    就是CallerID查出来是'12','13'
    现在CallID是'121212','131313'
    希望这样也能匹配,谢谢!
      

  4.   

    select * from SYS where exists(select * from SBS where charindex(callerid,sys.CallID)>0)
      

  5.   

    select * from SYS 
    where exists(
        select 1 from SBS where CallID like '%'+cast(a.CallID as varchar)+'%')
      

  6.   

    --还是说,要两边都可以模糊匹配?select * from SYS 
    where exists(
        select 1 from SBS 
        where CallID like '%'+cast(a.CallID as varchar)+'%'
             or a.CallID like '%'+cast(CallID as varchar)+'%')
      

  7.   

    select * from SYS a,(select distinct CallerID from SBS) b where cast(a.CallID as varchar like  '%'+b.CallerID +'%'
      

  8.   

    select *
    from SYS 
         inner join SBS on sys.CallerID like '%' + SBS.CallerID  + '%'select *
    from SYS ,sbs
    where sys.CallerID like '%' + SBS.callerid + '%'