Test table:EMP Table Sal TableLeft JOIN: Results All rows are displayed in the table, and the right table determines that the column is the same as the left.SELECT * FROM EMP left join SAL on EMP. ename = SAL. ename; Right join: Results All rows are displayed in the table on the le
Label:Original: http://blog.csdn.net/shadowyelling/article/details/7684714Left Join: Returns all the information in the table on the right and the information related to the left table conditionRight Join: Returns all of the information in the table in the list and information about the right table condition in the left
Let's start by looking at the results of the left join and the right join and the Inner join and the full join working on the table.
Create a new two table in the database and insert the data you want to test.
New table:[SQL]View PlainCopyUse [Test]GO/****** ob
Tags: http strong ar Data div sp on ad efLet's start by looking at the results of the left join and the right join and the Inner join and the full join working on the table.
Create a new two table in the database and insert the data you want to test.
New table:[SQL]Use
Label:Transferred from: http://blog.csdn.net/jz20110918/article/details/41806611 Let's say we have two tables. Table A is the sheet on the left. Table B is the list on the right. Each of them has four records, of which two records name is the same, as follows: Let's look at the different joins
Table A
Id
Name
1
Pirate
2
Monkey
3
Ninja
Take a look at the results of the left join and the right join with the Inner join and the full join to manipulate the table.
Create a new two table in the database and insert the data you want to test.
New table:[SQL]View PlainCopy
Use [Test]
GO
/*****
Differences between inner join, left JOIN, right join, outer join in SQLFor example, you'll know!Table A (A1,B1,C1) b (A2,B2)A1 B1 C1 A2 B201 Mathematics 95 01 Sheets Three02 Language 90 02 John Doe English Harry Select A.*, b.* from AINNER
This connection is often used in early query statements, which is a small problem. Therefore, I checked the information and summarized it as follows:
External connections are easier to understand,A. It is generally used in some classification codes. For example, if you have an employee information table, the position information isCodeAnd the meaning of this Code is described in the position table.B. Classified information storage. For example, in the preceding employee information table, the
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
The join syntax is as follows: select [field] from [Table Name 1] inner/left/right/full join [Table name 2] on [Table Name 1. field 1] [Table name 2. field 2] cross join: the product of the flute. without any constraints, the number of rows in a table is multiplied by the number of rows in another table.
[Test @ ora1] SQL> select * From A; No. Name ---- ---------- 1000 Zhang San 2000 Li Si 3000 Wang Wu [test @ ora1] SQL> select * from B; product NO. ---- ---------- 1000 TV set 2000 video recorder 4000 bicycle [test @ ora1] SQL> set null Null Value -- Here I define null as [null value] [test @ ora1] SQL> select. *, B. * From a inner join B on. no. = B. no.; No. name No. Product ---- ---------- 1000 Zhang San 1000 TV set 2000 Li Si 2000 video recorder [
--1.left Join left table is the primary table, left table returns all data, and the right table only returns data that matches the left table.Select T1.fpdm,t1.fphm, T1.ZJR,T1.ZJSJ,T1.ZJJX,T1.ZJJE,T1.ZFLX,T1.ZFID,T2.FPDM,T2.FPHM,T2.ZFLX from YW_ZJFPJL t1Left
Label:Simply and clearly, connect to the inner and outer links. Suppose there are two tables of A and B Internal connection: Inner JOIN indicates that the record of the AB table is displayed, excluding the condition of the AB table . There are three kinds of outer joins, that is, left OUTER joins, right connection, OUTER join, full OUTER
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
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
Tags: style blog c http a widthFor SQL joins, learning may be a bit confusing. We know that the join syntax for SQL has a lot of inner, outer, left, and sometimes it's not very clear what the result set looks like for a select. There is an article on Coding horror that explains the join of SQL through the Venn diagrams of the Venturi diagram. I feel clear and und
Left JOIN
will have two tables left or right in the join relationship. The left table after the "join", regardless of whether there is the right table data corresponding to the data, will still be all listed, the relevant example
Various joins in MySQL
1. Cartesian Product (cross join)
In MySQL, you can think of cross join or omit cross as join, or use ','
For example
Select * From Table1 cross join Table2
Select * From Table1 join Table2
Select * From Table1, Table2
Because the returned result is
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.