sql查找不重复数据 去重

SELECT  *
FROM    table1 a left join table2 as m on a.mid=m.mid
WHERE   EXISTS (

 SELECT 1  FROM    ( SELECT    MAX(gid) AS gid ,
                                    MAX(zhx) AS zhx ,
                                    gname
                          FROM      table1
                          GROUP BY  gname 
                    )  b
                    WHERE  a.gname = b.gname
                    AND a.zhx = b.zhx
                    AND A.gid = b.gid
                ) 

 

posted @ 2012-12-06 13:36  xyzhuzhou  阅读(479)  评论(0编辑  收藏  举报