oracle inline view

Hi I want to use fullouter join oracle

SELECT a.department_id
  FROM employees a,
       ( SELECT department_id  FROM department) b
 WHERE a.department_id = b.department_id

The above query is only giving matching rows ie., 10,20,30 but i want 40,50,60 and 70 can you please advise how can i use fullouter join in inline views. thanks.

employee.dept_id      department.dept_id
10                        10
20                           20      
30                              30
40                              60  
50                              70
Sarma VadlamaniprogrammeranalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
Not sure what you are trying to do as your query doesn't match your results.

The syntax should be:

SELECT a.department_id 
FROM   employees a 
       full outer join (SELECT department_id 
                        FROM   department) b 
                    ON a.department_id = b.department_id 

Open in new window

0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Doesn't look correct at all. Do you want to have the UNION of both IDs? Any ID being in at least one of both tables?
0
johnsoneSenior Oracle DBACommented:
No union should be required with the ANSI outer join syntax.  If we have sample data and expected results we should be able to do it without UNION.

A UNION would be required if you were trying to avoid the ANSI join syntax.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
If you think that way, you need to include both tables' results in the rowset:
SELECT coalesce(a.department_id, b.department_id)
FROM   employees a 
       full outer join (SELECT department_id 
                        FROM   department) b 
                    ON a.department_id = b.department_id 

Open in new window

but of course you would write this simple select more like
select coalesce(a.department_id, b.department_id)
from   employees a 
full join department b 
on a.department_id = b.department_id 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.