Oracle join usage

Source: Internet
Author: User

The following content describes the usage of Oracle join. If you have any questions about Oracle join, you can use the following articles to understand its practical application and functions, the following is a detailed introduction of the article. I hope you will gain some benefits after browsing the following content.

8i:

 
 
  1. create table dali.test1(a int,b int);  
  2. create table dali.test2(a int,b int);  
  3. insert into dali.test1 values(1,456);  
  4. insert into dali.test1 values(2,427);  
  5. insert into dali.test2 values(1,45456);  
  6. insert into dali.test2 values(3,45656); 

--- Internal connection

 
 
  1. select * from dali.test1 a, dali.test2 b where a.a=b.a; 

--- Left join

 
 
  1. select * from dali.test1 a, dali.test2 b where a.a=b.a(+); 

--- Right join

 
 
  1. select * from dali.test1 a, dali.test2 b where a.a(+)=b.a; 

--- Full connection

 
 
  1. select * from dali.test1 a, dali.test2 b where a.a=b.a(+)  
  2. union  
  3. select * from dali.test1 a, dali.test2 b where a.a(+)=b.a; 

--- Dikar

 
 
  1. select * from dali.test1, dali.test2; 

In Oracle join usage, 9i and sqlserver are the same as left join, right join, and full join.

Divided into 1.

 
 
  1. INNER JOIN 2. LEFT JOIN 3. RIGHT JOIN 4.LEFT OUTER JOIN 

First, set the two tables we want to use.

Table A Table B

ID NAME ID CLASS

1 IBM 1 C1

2 SONY 3 C3

3 BMW 4 C4

 
 
  1. 1 INNER JOIN: SELECT * FROM A INNER JOIN B ON A.ID=B.ID 

Table ID NAME CLASS

1 IBM C1

3 BMW C3

By the way, the IDs of both tables exist and the combined tables of the two tables are obtained.

2

 
 
  1. LEFT JOIN : SELECT * FROM A LEFT JOIN B ON A.ID=B.ID 

Table ID NAME CLASS

1 IBM C1

2 SONY null

3 BMW C3

In Oracle join usage, the related operations are complex. If there is A sense of direction, you can use LEFT to obtain all records of A (table on the left of the LEFT statement), and make up if the corresponding records of Table B do not exist.

3

 
 
  1. RIGHT JOIN : SELECT * FROM A RIGHT JOIN B ON A.ID=B.ID 

Table ID NAME CLASS

1 IBM C1

3 BMW C3

4 null C4

RIGHT (right) returns all records of B (table on the RIGHT side of the right statement). If the records of Table A do not exist, they must be completed (I have turned over too! Haha)

4

 
 
  1. FULL OUTER JOIN: SELECT * FROM A FULL OUTER JOIN B ON A.ID=B.ID 

Table ID NAME CLASS

1 IBM C1

2 SONY null

3 BMW C3

4 null C4

The above content is an introduction to the usage of Oracle join. I hope you will find some gains.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.