MySQL multi-table joint investigation and architecture as well as

Among multi-table associated with the query:

     Database operation, joint multi-table queries are commonly used in back-end developers to query.

JOIN

 

       SQL JOIN clause is used to combine two or more rows from the tables, the most common types of JOIN: the SQL the INNER JOIN (simple JOIN), SQL LEFT JOIN, SQL RIGHT JOIN, SQL FULL JOIN, wherein the former within connector, the last three being linked

According JOIN function divided into the following three categories:

    1. the CROSS the JOIN (cross-connect):

       Cross-connect and connection Cartesian product

             Carl product refers mathematics, two sets of X and Y Cartesian product Mi (Cartesian product), also known as the direct product, expressed as X × Y, the first object is a member of X and Y is the second object all possible ordered pairs of one of the members. Cartesian product called Cartesian product, is a man named Descartes put forward. Simply put, it is the result of multiplying two sets. Hypothesis set A = {a, b}, set B = {0, 1, 2}, the Cartesian product of two sets of {(a, 0), (a, 1), (a, 2), ( b, 0), (b, 1), (b, 2)}.

       Cross connection is that the performance of: multiplying the number of rows, columns are added

       Implicit cross-connect : the SELECT * the FROM A, B

       Show cross-connect: the SELECT * the FROM A  the CROSS the JOIN   B

   2. the INNER the JOIN (or equivalent connected to the connector)

         inner join connection is also called the equivalent connection , the two coupling using comparison tables matching rows in each table according to a total value column.

         Connected to the display: the SELECT * the FROM A  the INNER the JOIN   B = the ON A.id B.id

         Implicit within the connector: the SELECT the FROM A *, B = the WHERE A.id B.id

Notes: INNER JOIN and JOIN is the same.

3. OUTER the JOIN (external connection)

      Coupling may be left outside the outer join, the right outer coupling or full outer join. That is divided into an outer join: left outer join, right outer join, full outer joins, outer joins is required to retain the concept of the master table or tables

Left outer join (LEFT JOIN), and take a left set

 

Note: In some databases, LEFT JOIN is called LEFT OUTER JOIN.

LEFT JOIN keyword from the left table (table1) returns all rows, even if the right table (table2) does not match. If there is no match in the right table, the result is NULL
示例:SELECT  *  FROM  A  LEFT  JOIN  B ON A.id = B.id
 
Right outer join (RIGHT JOIN) taking right outer connector

 Note: In some databases, RIGHT JOIN is called RIGHT OUTER JOIN.

RIGHT JOIN right keyword table (table2) returns all rows, even if the left table (table1) does not match. If there is no match left table, the result is NULL.

 

Paging query:

      Keywords: LIMIT (MySQL 's unique syntax)

      Format: select * from table limit m, n
                 where m refers to the recording start index, starting from 0 , the first record indicates
                 n means from the first section m + 1, n pieces taken.
                 select * from tablename limit 2,4
                 i.e. extraction section 3 to Article 6, four records

Subquery:

     Subquery internal query yet, it allows a query nested within another query, the first query as the result of the second search criteria.

MySQL architecture:

 

 Implementation process:

 

 

      

Guess you like

Origin www.cnblogs.com/grow001/p/12109554.html