select tb1.col2
from tb1 ,tb2
where charindex(tb1.col1,tb2.col1)>0

解决方案 »

  1.   

    select  distinct tb2.col01  from tb2 left join tb1 on charindex(tb2.col01,tb1.col1)>0
      

  2.   

    select  distinct tb1.col02  from tb2 left join tb1 on charindex(tb2.col01,tb1.col1)>0
      

  3.   

    select distinct a.col2 from @talbe1 a,@talbe1 b
    where charindex(a.col1,b.col1)>0
      

  4.   

    DECLARE @T1 TABLE (col1 VARCHAR(20) ,col2 VARCHAR(2))
    INSERT INTO @T1
    SELECT '12345','a' UNION ALL
    SELECT '93','b' UNION ALL
    SELECT '2398','c'DECLARE @T2 TABLE (col1 VARCHAR(20))
    INSERT INTO @T2
    SELECT '1' UNION ALL
    SELECT '2' UNION ALL
    SELECT '8'select  distinct a.col2  
    from @t1 a,@t2 b 
    where charIndex(b.col1,a.col1)>0
    /*
    col2
    a
    c
    */