Learn about difference between inner join and outer join, we have the largest and most updated difference between inner join and outer join information on alibabacloud.com
First, the concept
1. Left join the left outer join
To the left table, go to the right table to find the same field, if more than one will be listed in sequence
2. Connect Join
Find the same records around the same
3. Fully connected full outer
simple because it is a left join, explained below: We know that the logic of the left join is a table or that the data in the primary table will appear in the final result set, so what does the "a.isdel=0" condition play in the process of the LEFT JOIN in statement 3? The function is that the system in the left joint, the first in a table with "a.isdel=0" condit
Label: Similarly, using the goods table to practice subqueries, the table structure is as follows: All data (cat_id associated with category.cat_id): Category table: Mingoods (test when connecting queries) First, sub-query 1,where sub-query: The result of the inner query as the comparison condition of the outer query 1.1 One item with the largest query ID (implemented using sort + paging) :mysql> SELEC
Label:--Build Table Table1,table2:CREATE TABLE table1 (ID int,name varchar (10))CREATE TABLE table2 (ID int,score int)Insert INTO table1 Select 1,leeInsert INTO table1 Select 2,zhangInsert INTO table1 Select 4,wangInsert INTO table2 Select 1,90Insert INTO table2 Select 2,100Insert INTO table2 select 3,70such as table-------------------------------------------------Table1 | table2 |-------------------------------------------------ID Name |id Score |1 Lee | 90 |2 Zhang 100 |4 Wang |3 70 |---------
columns in the connected table, including duplicate columns, are listed in the query results.
2. Unequal join: Use a comparison operator other than the equal operator to compare the column values of the connected columns. These operators include >,>=,
3. Natural join: Use the equal to (=) operator in the connection condition to compare the column values in the connected column. However, it uses the select
Inner join
There are two tables A and B.
The structure of Table A is as follows:
Aid: int; identifies the seed, primary key, and auto-increment ID
Aname: varchar
The data, that is, the records from select * From A, are shown in 1:
Figure 1: data in Table
Table B has the following structure:
Bid: int; identifies the seed, primary key, and auto-increment ID
Bnameid: int
Data, that
based on WHO, and only records meeting the conditions are displayed.--------------------------------------------Note:The left join operation is used to combine records of the source table in any from clause. Use the left join operation to create a left Outer Join. The outer
1. Internal Connection is simpleSelect a. *, B. * from a, B where a. ID = B. IDSelect a. *, B. * from a inner join B on A. ID = B. IDThe above two statements are completely equivalent.
2. left Outer JoinSelect * from EMP a left join dept D on A. deptno = D. deptnoSelect * from emp a, DEPT d Where a. deptno = D. deptno
A. =
Eg.
Select a. a B. B from a, B where a. A = B. A and A. C = 'herengang ';
Under this condition, it only shows the data that a. A = B. A and A. C = "herengang ".
Although it there is data which. C is "herengang", but if we can't find such record which. A value equals to. A in Table B, then it will be cleared.
B. Left join
Select a. a, B.
From Table
Left join Table B
On a. A = B. A and A. C = "herengang"
2006032402
3 a20050113 3 2006032403
4 a20050114 4 2006032404
Null null 8 2006032408
(The number of affected rows is 5)
Result description:
After careful observation, we will find that the result of left join is exactly the opposite. This time, it is based on the right table (B) and is filled with null when table A is insufficient.
3. Inner join
The SQL stateme
data in both tables is displayedLeft join: Understood to be "there is display", such as on A.field=b.field, displays all the data present in table A and the data in A and B, the data in A and B does not appear as nullRight join: Understood to be "show on display", such as on A.field=b.field, displays all the data present in table B and the data in A, B, and the data in B that is not in a, null displayFull
connection A and B table is the same as the result of the left coupling B and a, which means:
Select A.name B.name from the left of Join B on A.id=b.id
And the result of the execution of the select A.name b.name from B right Join A is the same.
3. Full join: Takes out all records of a joined field in two tables to form a recordset's
The following articles mainly describe the table connection statements for Oracle Outer join and cross join. Oracle database connections include the inner join statements) oracle Outer join
. This is the most frequently used join type. The Inner join combines the records in these tables only if there is a matching value on the public field of the two tables. The ability to use INNER JOIN for departments and Employees tables to select all employees in each depar
two tables. You can use INNER JOIN for departments and Employees tables to select all employees in each department. Instead, you can create an outer join by using a LEFT JOIN or right JOIN operation to select all the parts (even
I. Let's take a look at some of the simplest examples.
Example
TableAid adate1 a12 a23 a3
TableB
Bid bdate1 b12 b24 b4Two tables a and B are connected. fields with the same id must be retrieved.Select * from a inner join B on a. aid = B. bid this is only used to retrieve matching data.In this case, the following information is taken:1 a1 b12 a2 b2
Then left join
I. Let's take a look at some of the simplest examples.
Example
TableAid adate1 A12 A23 A3
Tableb
Bid bdate1 B12 B24 B4Two tables A and B are connected. fields with the same ID must be retrieved.Select * from a inner join B on A. Aid = B. Bid this is only used to retrieve matching data.In this case, the following information is taken:1 A1 B12 A2 B2
Then left jo
Label:Left join the left JOIN, That is, the meaning of the left outer join is that the data in the table that restricts the right end of the connection keyword must satisfy the join condition , and the contents of the left-hand table are output if the data in the table in th
own is implemented in the first way, the focus on the index, statistics, and so on above, how can not find the reason Found in poor performance itself here I just cite a simple example that is actually difficult to simulate the actual logic This question puzzled me for a long time, At first, I didn't think of the reason for the difference between filtering and directly placing in the where condition using the IN
The difference between an inner join and an equivalent connection
url:http://blog.csdn.net/dba_waterbin/article/details/8458193
The inner join is the result set that satisfies the join condition, which is relative to the
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.