select distinct a.fundcode,a.fundnameabbr,a.pinyincode from tb_fundarchive a ,tb_fundnetvalue b where 
a.isdeleted = 0 and a.fundtype = 7 and a.fundcode = b.fundcode
and (a.fundcode like '%021%' or a.pinyincode like '%021%' or a.fundname like '%021%' or a.fundnameabbr like '%021%')

解决方案 »

  1.   

    看上去没什么问题,可以分段进行查询,看看问题到底出在哪儿。select distinct a.fundcode,a.fundnameabbr,a.pinyincode 
    from tb_fundarchive a ,tb_fundnetvalue b 
    where a.isdeleted = 0 and a.fundtype = 7 
    and a.fundcode = b.fundcode---注意内连接要有符合的条件,否则就查不到数据。
    and (a.fundcode like '%021%' or a.pinyincode like '%021%' 
         or a.fundname like '%021%' or a.fundnameabbr like '%021%')
      

  2.   

    刚接触到T-Sql ,看到这里用到了distinct,所以想问一下,是不是有这种可能:比如:表1和表2 利用内部连接,有可能返回两行完全一样的数据?包括惟一标识都一样?
    前两天我就遇到了这个问题,
    还望能指教一下!在此谢了!
      

  3.   

    有可能出现这样的情况。
    加上distinct应该是可以的,mysql确实没用过。不太了解。
      

  4.   

    mysql的左连接、右连接和内连接详解
      

  5.   

    从语法上未看出有什么错误,请确保是否存在数据?
    select distinct a.fundcode,a.fundnameabbr,a.pinyincode 
    from tb_fundarchive a ,tb_fundnetvalue b 
    where a.isdeleted = 0 and a.fundtype = 7 and a.fundcode = b.fundcode
    and (a.fundcode like '%021%' or a.pinyincode like '%021%' or a.fundname like '%021%' or a.fundnameabbr like '%021%')