Home > Database > Mysql Tutorial > body text

Commonly used basic operation syntax of mysql (9) ~~External join query [command line mode]

黄舟
Release: 2017-03-03 14:21:10
Original
1750 people have browsed it

1. Left outer join or left jion, outer can be omitted, and the same is true for the right join and full join below:


left The meaning of outer join is to use the data in the table on the left side of the left join as the basis, that is, all the data in the table on the left must be displayed, as shown below:


In the first query here, the company table is on the left, so company is used as the benchmark. Therefore, in addition to the 6 pieces of data with the same part_id, the displayed results also display another piece of data that exists in company.

In the second query, emp is on the left, and emp is used as the basis. Therefore, in addition to the 6 items with the same part_id, the displayed results also display another item that exists in emp.

2. Right outer join right join:


From the perspective of the two queries above, except for the difference in field order , which is very similar to the operation of left outer join. It's just that one is based on the table on the left of left join, and the other is based on the table on the right of right join. (Some friends say that the performance of left join is better. I will ignore this for now and wait until the performance test.)

3. Full join. This is slightly different from the above in that there is no need to use it in the syntax. Use on after join to directly select the field name from tablename1 full join tablename2; and its result will also show the Cartesian product phenomenon mentioned before, that is, it will display (the number of fields in table 1 plus the number of fields in table 2) fields , display (the number of records in Table 1 multiplied by the number of records in Table 2) records;


The above is the common basic operation syntax of mysql (9)~~external Connect to query the content of [Command Line Mode]. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template