Two methods for implementing MySQL multi-table join query

Source: Internet
Author: User

If you need to implement MySQL multi-table join query, how can this problem be achieved? The following describes two common methods for implementing MySQL multi-table join query.

MySQL multi-table join query example:

The following two MySQL multi-table join methods can be used, and inner join on is better. The table structure is not pasted out, but it is easy to understand.

A Simple Method for MySQL multi-table join query:

 
 
  1. select c.nom, e.nom   
  2. from consultant c, affaire a, besoin b, salarie sa, site s, entreprise e  
  3. where c.consultant_id=a.consultant_id and a.besoin_id=b.besoin_id and   
  4.  
  5. b.salarie_id=sa.salarie_id and ssa.site_id=s.site_id and s.entreprise_id=e.entreprise_id  

The inner join method for MySQL multi-table join:

 
 
  1. select c.nom, e.nom  
  2. from consultant c  
  3. inner join affaire a on c.consultant_id=a.consultant_id  
  4. inner join besoin b on a.besoin_id=b.besoin_id  
  5. inner join salarie sa on b.salarie_id=sa.salarie_id  
  6. inner join site s on ssa.site_id=s.site_id  
  7. inner join entreprise e on s.entreprise_id=e.entreprise_id  
  8.  

Take you to understand mysql Variables

How to revoke permissions and delete MySQL users

Back up and restore a database using MySQL Command Line

How does one forget the MySQL root User Password?

How to deal with MySQL function creation Problems

Related Article

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.