Oracle Full connection processing connection field display not complete problem

Source: Internet
Author: User

Existing Oracle Table A table B

ID COLA ID COLB

1 1 2 4

2 2 3 5

3 3 4 6

Full JOIN operation for table A and table B sql1:select t.id,cola,colb from (SELECT * from A) T fully Join (SELECT * from B) R on T.id=r.id

The result is ID COLA COLB

1 1

2 2 4

3 3 5

6 because the SQL1 selected is T.id (that is, the ID of a), so the full connection after the connection field will only display the ID of a, and B's ID is null

Similarly, if you choose r.id (that is, the ID of B) The result is that the ID of a is null Sql2:select r.id,cola,colb from (SELECT * from A) T full JOIN (SELECT * from B) R on T. Id=r.id

ID COLA COLB

1

2 2 4

3 3 5

4 6

The result table is processed to Sql3:select a| | B as Id,cola,colb from (select T.id as a,r.id as B,cola,colb from (SELECT * from A) T full JOIN (SELECT * from B) R on T.I D=r.id) WHERE A is null OR B was null UNION all SELECT A as Id,cola,colb from (select T.id as a,r.id as B,cola,colb FRO M (SELECT * from A) T full JOIN (SELECT * from B) R-t.id=r.id) WHERE A is isn't null and B is NOT NULL

Get the ID in table a table B alias a B, and then merge the AB column into 1 column ID, that is, AB is not empty then take one of them, the Union AB has an empty, take a| | b You can

A B COLA COLB

1 1

2 2 2 4

3 3 3 5

4 6

Finally get

ID COLA COLB

1 1

2 2 4

3 3 5

4 6

Oracle Full connection processing connection field display not complete problem

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.