File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and Relational Databases and the fly likes Left outer join or Right outer join on Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Left outer join or Right outer join on Oracle" Watch "Left outer join or Right outer join on Oracle" New topic
Author

Left outer join or Right outer join on Oracle

Tejas Jain
Ranch Hand

Joined: Mar 04, 2008
Posts: 119
I have two tables: employee and department. The employee table has a foreign key dep_id pointing to the primary key, dep_id, of the department table.

Outer Left Join: SELECT d.name, e.name FROM department d, employee e WHERE d.dep_id = e.dep_id (+);

Do I get a Outer Right Join by just switching the sides on equal sign (=) like following?
SELECT d.name, e.name FROM department d, employee e WHERE e.dep_id (+) = d.dep_id;

They are both valid SQL statements. I guess the result set should be the same. Correct?



"Knowing is not enough, you must apply... Willing is not enough, you must do."
--Bruce Lee
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3717
    
  61

Yes, the two statements are identical.

Similarly with the ANSI syntax, a left join can always be expressed as a right join (and vice versa), simply by reversing the order of the tables.
 
Don't get me started about those stupid light bulbs.
 
subject: Left outer join or Right outer join on Oracle
 
It's not a secret anymore!