資料庫中多表的串連

來源:互聯網
上載者:User

1.外串連

select   *   from  T_N  left  join  T_S  on   T_N.id=T_S.id 
 

select   *   from  T_N  right  join  T_S  on   T_N.id=T_S.id 

select * from T_N full join T_S on T_N.id=T_S.id 

2.內串連

select   *   from   T_N   join   T_S   on   T_N.id=T_S.id 

3.交叉串連

select   *   from   T_N  cross  join   T_S  

最後的總結

//建立的有外串連的儲值總和、消費總和的視圖
SELECT Recharge_Info.CardID, Line_info.cardID AS LcardID, SUM(Recharge_Info.AddMoney) AS sumAddMoney, SUM(Line_info.consume) AS sumConsumeFROM  Line_info RIGHT OUTER JOIN  Recharge_Info ON Line_info.cardID = Recharge_Info.CardIDGROUP BY Recharge_Info.CardID, Line_info.cardID


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.