我的好友 (user_user_friend  [id,   user_id int(11,index),   friend_id(int[11]),    input_time(datetime)])
建立一个 好友的关联表 id自动增长的  user_id 是我自己的关联 id  friend_id  是好友的关联id  
我怎么查询两个表 能查出 我的一个 user_id =6  的好友的详细信息 

解决方案 »

  1.   

    好友信息表friend
    select * from friend,user_user_friend  where user_user_friend.user_id=6 and user_user_friend.friend_id=friend.id;
      

  2.   

    id 用户关联id  好友关联id
    1   2        4
    2   2        45
    3   2        35
    4   2        11
    5   2        1
    6   2        41
    7   6        1
    8   4        2
      

  3.   


    select a.fields, b.fields from a, b where a.id = b.id
      

  4.   

    select a.fields, b.fields from a, b where 6 = b.id
      

  5.   

    我先要 通过 用户的id 关联 user 表  查出有关联的数据
    然后 用户id 后边的 好友关联id  我想要的就是 好友id 的详细 信息
      

  6.   

    select a.id, a.uname, b.* from a, b where a.id = b.id假如a用户表,b好友表
      

  7.   

    但是 这样查出来的是 用户的 个人资料 
    我想要的 是 好友的用户资料
     两个表格 通过 用户的 id 先进行一次关联
    能查出 这个用户的所有好友
    但通过 好友 id 的关联 查出 好友的资料
      

  8.   

    select * from t where 条件 in/= (select * from t where ...)