用SQL语句连接三个或者多个表呀

解决方案 »

  1.   

    select a.aa,b.bb,c.cc 
    from a,b,c
    wher a.id=b.id and a.id=c.id或者
    select a.aa,b.bb,c.cc 
    from a  inner join b on a.id=b.id .....
      

  2.   

    Select Table1.Field1, Table2.Field1, Table3.Field1
    From Table1, Table2, Table3
    Where Table1.ID=Table2.ID and Table2.ID=Table3.ID
      

  3.   

    不等连接
    SELECT PersonInfo.userId, PersonInfo.userName, FpImage.FpImage1, Photo.Photo
    FROM (FpImage RIGHT JOIN PersonInfo ON FpImage.UserID = PersonInfo.userId) LEFT JOIN Photo ON PersonInfo.userId = Photo.UserID;
    相等连接
    SELECT PersonInfo.userId, PersonInfo.userName, FpImage.FpImage1, Photo.Photo
    FROM (FpImage INNER JOIN PersonInfo ON FpImage.UserID = PersonInfo.userId) INNER JOIN Photo ON PersonInfo.userId = Photo.UserID;
      

  4.   

    用in语句
    select * from a where a.id in (select id from b where a.id=b.id)