MySQL Foundation-database Multi-table query-record (vi)

Source: Internet
Author: User

0x01

MySQL multi-table query and sub-query

Join query: Two or more tables joined in advance, based on the results of the join query

Cross join: Less intersection, equivalent to (a+b) * (c+d+e) of the resulting form with less


Natural Coupling---can only be connected if they are equal
Equivalent junction: Connect the same field to the equivalent

Outer coupling:
Left OUTER join: Only the tuples that appear in the relationship before the left outer join element (left) are retained (whichever is left table)
Left_tb left JOIN RIGHT_TB on condition
Right outer join: only tuples in the relationship that appear after the right outer join element (right) are preserved (whichever is the right table)
LEFT_TB right JOIN right_tb on condition
Full outer joins: less ---

Self-coupling:

Alias: As
Table Aliases:
Field aliases

Subqueries: Queries nested in queries------for subqueries in where
1. To compare subqueries in an expression
The return value of a subquery can have only one
2. Subqueries used in exists
Judging the existence or not
3. Subqueries for in
The judgment exists in the specified list
For the From Neutron query
Select Alias.col,.... From (SELECT Cluse) alias WHERE condition

MySQL is not good at subqueries, you should avoid using sub-queries

Summary: MySQL connection query and sub-query
Join:
Cross join:
Inner coupling:
Outer coupling:
Left outer
Right outside
Self-coupling
Sub-query:
Subqueries used in where
For condition comparison:
For exists
For in
For the From

MySQL's federated query:
Combine the results of two or more query statements into one result for output
Select Clauase UNION SELECT Clause union .....
Index
Show Indexs from Tb_name View index

show indexes from Students\g;


ALTER TABLE Tb_name Add index (field)---change to index
Create an index

Explain interpret the command to see the execution of the command

MySQL view (virtual table)
The SELECT statement that is stored
Create:
CREATE VIEW name as SELECT statement

CREATE VIEW stud as select Name,age,gender from students;
Delete:
Drop View Name

MySQL Foundation-database Multi-table query-record (vi)

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.