Multi-Table connection in the database

Source: Internet
Author: User

1. External Connection

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. Internal Connection

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

3. Cross join

select   *   from   T_N  cross  join   T_S  

Conclusion

// View of the total number of recharged and consumed items with external connections established
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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.