1 LEFT JOIN: The query results are based on the left table data. If the left table has four data, the right table has three data, the query result is four, and all the data in the left table.For example:EMP Table:Sal table:Left connection Select * from EMP left join SAL on
EMP. ename = SAL.ename; Left JOIN,
Code is as follows:
Copy code
SELECT * FROMInner join BON a. aID = B. bID
Equivalent to the following SQL statement:
The Code is as follows:
Copy code
SELECT *FROM a, BWHERE a. aID = B. bID
The result is as follows:AID aNum bID bName1 a20050111 1 20060324012 a20050112 2 20060324023 a20050113 3 20060324034 a20050114 4 2006032404
Result description:Obviously, only the records of A. aID = B. bID are di
: SELECT * from a LEFT join B on a.aid = B.bid First Remove all the data in the a table, and then add the data that matches a A, then take out is: 1 A1 B1 2 A2 B2 3 A3 null character Similarly, right join refers to the first to remove all the data from table B, and then add the data that matches a a, and then take out the following: 1 A1 B1 2 A2 B2 4 null charac
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 ta
First, take a look at some of the simplest examples.
Example
Table AAid Adate1 A12 A23 A3
TableB
Bid Bdate1 B12 B24 B4Two table a,b connected, to remove fields with the same IDSELECT * from a INNER join B on a.aid = B.bid This is the only matching data to be fetched.At this point, the removal is:1 A1 B12 A2 B2
So the left join means:SELECT * from a LEFT join
Equivalent to the following SQL sentence:
The code is as follows
Copy Code
SELECT *From A,bWHERE A.aid = B.bid
The results are as follows:AID Anum BID bname1 a20050111 1 20060324012 a20050112 2 20060324023 a20050113 3 20060324034 a20050114 4 2006032404
Results show:Obviously, only the record of A.aid = B.bid is shown here. This shows that inner join is not based on who, it only shows the records that
. 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 department. Instead, you can create an outer
The outer join in the query from statement can be simplified in many cases;In the parsing phase, the right outer JOIN operation can be turned into an ode value containing the left JOIN operation, in general, the transition:
. 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 department. Instead, you can create an outer join through a LEFT
. 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 department. Instead, you can create an outer join through a LEFT
. 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 department. Instead, you can create an outer join through a LEFT
clause. 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 department. Instead, you can create an outer
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
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 if there are no employees assigned in some departments) or all employees (even if so
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 if there are no employees assigned in some departments) or all employees (even if so
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 if there are no employees assigned in some departments) or all employees (even if so
. 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 department. Instead, you can create an outer join through a LEFT
.
**************************************** **************************************** ************
Recently, the company is recruiting people. My colleagues asked a few questions about database connection that I think the database can be applied ~Now I want to write about their functions here.Assume that the following table is used:
One is the voting master table, and the other is the voter information table ~ Record the IP address of the voter and the corresponding voting type. The left-
point, the removal is:1 A1 B12 A2 B23 A3 NULL characterThe same is trueRight join Refers to the first to remove all the data in the B table, and then add the data that matches theAt this point, the removal is:1 A1 B12 A2 B24 NULL character B4Left JOIN or left OUTER join.The result set of the left outer
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.