select distinct(a.objid),a.*,u.username as objusername from usr_action_other a,usr_user u where a.type=1 and a.username=u.username and a.objid=u.userid and a.username='%s' order by a.crtime desc limit %d,%d 

解决方案 »

  1.   

    先谢谢二楼。
    不过不好意思噢。你的没有解决我的问题呀
    a.objid对应u.userid是对的,但a.username不对应u.username
    因为a.userid和a.username是发起动作的用户,而a.objid才是对应接收动作的用户。上面的语句我把a.* 去掉了以后就好了,但一加上去就不对了。不知道是为什么。
      

  2.   

    你 的a.*中已经有一个a.objid了,你distinct(a.objid)得到的列名也是a.objid,重复了;
    这样 select distinct(a.objid) as a_objid,a.*..........
      

  3.   

    搞定了。
    是少了group by 
    不过不是谢谢二楼的兄弟。