不对的,因为是多表查询,因为查出的gid是不同的,每条记录都不是同一条的.只是一条记录中的相同字段~
而distinct是消除重复记录所以不行的..

解决方案 »

  1.   


    SELECT contact.id,contact.name from contact left join contact_grouper contact_grouper.id=contact.id where contact_grouper.gid!='$gid'
      

  2.   

    是的,我要显示此工作组的用户,另一边显示不存在此工作的用户吗?
    但是一个用户可能在多个组里,所以用!='$gid'还不够...
    如果mysql能支持子查询就好了,再查一下该表的用户,不等用姓名就行了..
    55555555555555,各位高手救命啊~
      

  3.   


    你试一下这一句是否可以
    SELECT contact.id,contact.name from contact left join contact_grouper contact_grouper.id=contact.id where contact_grouper.gid!='$gid'
    不在此工作组的用户。
      

  4.   

    试试:SELECT contact.id,contact.name from contact,grouper,contact_grouper where contact_grouper.gid='$gid' and contact_grouper.id=(select id from contact where contact.id and contact_grouper.gid=grouper.gid)