如图,
select a.Hostname,a.Loginname,a.Software,b.[Software Name] from app a,lc b where  a.hostname=b.[device name] and a.loginname=b.[login name]
 ,上图是我根据sql 查询出的数据,现在要把software 和 [Software Name]能对应上的找出来,比如HostName 为
AMYHU 的查询结果为:http://hi.csdn.net/attachment/201103/15/0_1300173659b828.gif ,注意: 打个比方:software='Adobe Photoshop 4.0' [software name]='Adobe Photoshop ' 这个也能对得上,所以不能用=查询 

解决方案 »

  1.   

    比如HostName  的查询结果为:
      

  2.   

    select
      *
    from
      tb t
    where
     exists(select 1 from tb where HostName!=t.HostName and software=software  and [Software Name]=t.[Software Name])
      

  3.   

    用游标吧,将相等的数据行,记录下来。在输出。记录可以用一个字符串,记录每一行的id,没有id可以虚拟一个,然后把这个字符串分解,得到的结果便是!
      

  4.   


    select * from (
    select a.Hostname,a.Loginname,a.Software,b.[Software Name] from app a,lc b where  
    a.hostname=b.[device name] and a.loginname=b.[login name]
    ) a  where a.Software like b.[Software Name]+'%'
      

  5.   

    select * from (
    select a.Hostname,a.Loginname,a.Software,b.[Software Name] from app a,lc b where  
    a.hostname=b.[device name] and a.loginname=b.[login name]
    ) a  where '%'+a.Software+'%' like '%'+b.[Software Name]+'%'