Use left join and inner join in SQL.
Left join on is a left Outer join. The data is based on the table on the left. The table data on the right is queried even if it is null,
Inner join on means that the data in the tables on both sides of the left and right must correspond to each other. If there is null, the data will be removed. If
If the data in the right or left table is null, no result set is found. The two connections work together to achieve excellent results.
For some requirements, we need to work with these two join queries.
Differences between inner join, left join, right join, and outer join in SQL
For example, you will know!
Table A (a1, b1, c1) Table B (a2, b2)
A1 b1 c1 a2 b2
01 mathematics 95 01 Zhang San
02 language 90 02 Li Si
03 English 80 04 Wang Wu
Select A. *, B. * from
Inner join B on (A. a1 = B. a2)
The result is:
A1 b1 c1 a2 b2
01 mathematics 95 01 Zhang San
02 language 90 02 Li Si
Select A. *, B. * from
Left outer join B on (A. a1 = B. a2)
The result is:
A1 b1 c1 a2 b2
01 mathematics 95 01 Zhang San
02 language 90 02 Li Si
03 English 80 NULL
Select A. *, B. * from
Right outer join B on (A. a1 = B. a2)
The result is:
A1 b1 c1 a2 b2
01 mathematics 95 01 Zhang San
02 language 90 02 Li Si
NULL 04 Wang Wu
Select A. *, B. * from
Full outer join B on (A. a1 = B. a2)
The result is:
A1 b1 c1 a2 b2
01 mathematics 95 01 Zhang San
02 language 90 02 Li Si
03 English 80 NULL
NULL 04 Wang Wu
SQL server 2005 connection query (inner join, left join, right join)
Inner join: inner join. The result only contains columns that meet the conditions.
Left join: left Outer join. The result contains the rows that meet the conditions and all rows in the left table.
Right join: right outer join. The result contains the rows that meet the conditions and all rows in the right table.