这是两张表:C_User_Role_Premission ,C_User_Premission ,
我想根据C_User_Role_Premission.role_pid=C_User_Premission.pre_id这个条件来获得两张表的全部信息,怎么实现啊??

解决方案 »

  1.   

    Select A.*,B.* from C_User_Role_Premission A 
    LEFT JOIN C_User_Premission B ON A.role_pid=B.pre_id
      

  2.   


    select a.*,b.* from C_User_Role_Premission a inner join C_User_Premission b on 
    a.role_pid=b.pre_id
      

  3.   


    select * from C_User_Role_Premission ,C_User_Premission where C_User_Role_Premission.role_pid=C_User_Premission.pre_id
      

  4.   


    select a.*,b.* from C_User_Role_Premission as a inner join C_User_Premission as b on 
    a.role_pid=b.pre_id
      

  5.   

    select * from C_User_Role_Premission a full join C_User_Premission b on a.role_pid=b.pre_id
      

  6.   

    不知道是不是理解错了楼主的意思,看上面的全是inner join ,那样取出来的是条件匹配的值。
    但是我看楼主要的是两个表的全部信息。所以用了个full join, 这个取出来的是两个表所有的信息,当条件(C_User_Role_Premission.role_pid=C_User_Premission.pre_id)满足时,是一条记录,当不满足时(也就是两个表中不满足的字段)则为null
      

  7.   

    结果是这样,楼主自己看需要那个吧:
    select * from a
    aid    adata
    1 1
    2 2
    3 3
    4 4select * from b
    bid    bdata
    3 3
    4 4
    5 5
    6 6select * from a a full join b b on a.aid=b.bid //这是full join
    aid    adata    bid     bdata
    1 1 NULL NULL
    2 2 NULL NULL
    3 3 3 3
    4 4 4 4
    NULL NULL 5 5
    NULL NULL 6 6select * from a a inner join b b on a.aid=b.bid//这是inner join
    aid    adata    bid     bdata
    3 3 3 3
    4 4 4 4