The difference between the left join of SQL, right join, INNER joinLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER
The difference between the left join of SQL, right join, INNER joinLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER
Left join, join, right join difference, leftjoinLeft join returns records that include all records in the left table and join fields in the right table.Right join returns records that include all records in the right table and the
[/Color] [color = Green] Table A records as follows:Aid anum1 A112 A223 A334 A445 A55
Table B records the following:Bid bname1 B112 B223 B334 b448 b88
The SQL statements for creating these two tables are as follows:Create TableAid int (1) auto_increment primary key,Anum char (20))Create Table B (Bid int (1) not null auto_increment primary key,Bname char (20))
INSERT INTOValues (1, 'a11 ');Commit;.....
Insert into BValues (1, 'b11 ');Commit;.....
1. Left join
The following is an exampleTable A records the following:Aid anum1 a200501112 a200501123 a200501134 a200501145 a20050115
Table B records the following:Bid bname1 20060324012 20060324023 20060324034 20060324048 2006032408
The SQL statements for creating these two tables are as follows:Create TableAid int (1) auto_increment primary key,Anum char (20))Create Table B (Bid int (1) not null auto_increment primary key,Bname char (20))
INSERT INTOValues (1, 'a20050111'), (2, 'a20050112'), (3, 'a20050113
EFT Join (left JOIN) returns records that include all records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join
Tags: operations same field record group type search using left join firstLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JO
Label:Left join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns only rows that have the same
Table connection methods and usage scenarios
NESTED LOOP
For a small subset of connected data, nested loop connection is a good choice. The nested loop is used to scan a table. Every time a record is read, it is searched in another table based on the index. Without an index, it is generally not nested loops.Generally, in the nested loop, the result set of the driver table meeting the condition is not large, and the connected fields of the driver table must be indexed, so that nstedloop is used.
Here is an example analysis
Table A records as follows:
AID Anum
1 a20050111
2 a20050112
3 a20050113
4 a20050114
5 a20050115
Table B is recorded as follows:
BID bname
1 2006032401
2 2006032402
3 2006032403
4 2006032404
8 2006032408
Create the two tables SQL statements as follows:
CREATE TABLE A
AID Int (1) auto_increment PRIMARY KEY,
Anum Char (20)
)
CREATE TABLE B (
BID Int (1) not NULL auto_increment PRIMARY KEY,
Bname Char (20)
)
INSERT into a
VALUES (1, ' a20050111 '), (2, ' a20050112 '),
Tags: case ble add left join Karl Baidu Oss intersection useUsing the Join table, the defect is inner join, the left join used in development and the right join belong to outer join,outer join
Left join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns only rows that have the same
Label:Left join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns only rows that have the same
Tags: relationship body syntax base padding Local Data type example conditionsLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent
Left join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns only rows that have the same
Tags: using SP data on BS EF SQL nbsp CLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns
Tags: left joins right join INNER JOINLeft join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent
Label: Left join returns records that include all the records in the left table and the equivalent of the junction fields in the right tableRight join returns records that include all records in the right table and the junction fields in the left tableINNER JOIN (equivalent join) returns only rows that have the same
Tags: description database table selection No related detailed associated demo postFirst, let's look at some of the simplest examples. Example Table AAid Adate1 A12 A23 A3 TableB Bid Bdate1 B12 B24 B4Two tables A, B connected, to remove fields with the same IDSELECT * from a INNER join B on a.aid = B.bid This is only the matching data is taken out.At this point, the removal is:1 A1 B12 A2 B2Then the left join
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.