Mysql connection Query

Source: Internet
Author: User

Mysql connection query:

MysqlConnection query supports multi-Table connection

 

 

 

 

Get a table:

Method 1: (subquery and connection query are mixed)

Step 1:

 result.id, t_name  h_name,match_time,result  teams   result  teams.t_idresult.h_id

Step 2:

 result.id ,t_name  g_name  teams   result  teams.t_idresult.g_id

Get

 t1.id,h_name,g_name,result,match_time  result.id, t_name  h_name,match_time,result  teams   result  teams.t_idresult.h_id)  result.id ,t_name  g_name  teams   result  teams.t_idresult.g_id)  t1.idt2.id;

You can get

The result is coming out, a little tedious.

 result.id,t1.t_name  h_name ,t2.t_name  g_name ,result,match_time  t1  result.h_id t2  t2.t_idresult.g_id;

You can get:

TeamsTable to be connected2So there must beAlias

 

 

 

 t1.name  p_name,t2.name  son_name  subject  t1  subject  t2  t1.idt2.pid;

 

You can get

 

 

 

To facilitate the exercise, or to obtain the SQL statement for table creation and data filling, click to obtain the exercise SQL.

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.