Oracle left Outer and right outer

Source: Internet
Author: User

Create or replace view V_WTK_ALL

Select a. id, o. short as FindDeptName, u. realname as FindUserName, f. name as FindWay, o1.short as ProblemAtDeptName,

Z. name as szzz,. yhnr, s. name as SSZY, k. name as kind, w. name as whhg,. zgcs,. zgfzr,. plandate,. finishdate,

U1.realname as jdr, u2.realname as fxr, a. yqzt, a. yqdate, a. wtkzt

From WTK a, ORGANIZATION o, ORGANIZATION o1, OPERATORS u, OPERATORS u1, OPERATORS u2, Kind k, Findway f, SPfield s, SZZZ z, WHHG w

Where. finddeptid = o. id (+) and. problematdeptid = o1.id (+) and. finduserid = u. id (+) and. jdr = u1.id (+) and. fxr = u2.id (+)

And. kindid = k. id (+) and. findwayid = f. id (+) and. spfieldid = s. id (+) and. szzid = z. id (+) and. whhgid = w. id (+)

There are two tables

Table1

User_id user_name user_pss

1 aaa

2 bbb B

3 ccc c

Table 2

User_id user_power

1 111000

2 000111

Query using SQL statements

Normal status:

Select table1.user _ id,

Table1.user _ name,

Table2.user _ power

From table1, table2

Where table1.user _ id = table2.user _ id

However, only two pieces of data are retrieved:

User_id user_name user_power

1 aaa 000111

2 bbb 111000

Enter the text you want to convert,

Click the button below to perform online conversion.

Select table1.user _ id, table1.user _ name, table2.user _ power

From table1, table2

Where table1.user _ id (+) = table2.user _ id

The following result is displayed:

User_id user_name user_power

1 aaa 000111

2 bbb 111000

3 ccc (null)

Note: The left or right join query specifies the table data to be queried. The default value (Left or Right join is not specified) is the data with key columns in both tables.

Internal join is a record of the corresponding values of the connected fields in both tables before data can be retrieved.

The left join means that data can be retrieved as long as there are records in the left table, and some records on the right can be retrieved only when there are records in the left table.

Right join: data can be retrieved as long as there are records in the right table.

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.