本帖最后由 xyflash 于 2011-08-22 21:15:52 编辑

解决方案 »

  1.   

    这是所谓的“自连接”查询,如下为示例:mysql> select a.*
    from a, a as b
    where a.uid = 1 and a.uid = b.sid and a.sid = b.uid;
    +-----+-----+
    | uid | sid |
    +-----+-----+
    |   1 |   2 |
    |   1 |   3 |
    +-----+-----+
    2 rows in setmysql> 
      

  2.   

    表中没有唯一标识的字段,加入自增字段ID
    select a.*
    from ttr a, ttr b
    where  a.id<b.id and a.uid = b.sid and a.sid = b.uid and a.uid=1;
      

  3.   

    select * from 表A t1 ,表A t2 
    where t1.uid=t2.sid 
    and t1.sid=t2.uid
    wand t1.uid=1