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 the fly likes regarding left outer join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "regarding left outer join" Watch "regarding left outer join" New topic
Author

regarding left outer join

prateek sharmaa
Ranch Hand

Joined: May 15, 2010
Posts: 38
hi all,
this is regarding left outer join.
suppose i have the below tables (took this example from wikipedia)

Employee Table
LastName DepartmentID
Rafferty 31
Jones 33
Steinberg 33
Robinson 34
Smith 34
John NULL

Department Table
DepartmentID DepartmentName
31 Sales
33 Engineering
34 Clerical
35 Marketing

now if i execute the below query on ORACLE database :

SELECT LastName, DepartmentName FROM employee, department WHERE employee.DepartmentID = department.DepartmentID(+)

then i will get the below result

LastName DepartmentName
Rafferty Sales
Jones Engineering
Steinberg Engineering
Robinson Clerical
Smith Clerical
John


i will not get any department name for john as i have used left outer join.

so now my question is that if i want to put some default department name for all those entries for which department name is null then is there any way to do that like if i want to mention department name as "no department" for john then how can i do that?

thanks,
pratz
Sudheer Bhat
Ranch Hand

Joined: Feb 22, 2011
Posts: 75
prateek sharmaa
Ranch Hand

Joined: May 15, 2010
Posts: 38
thanks a lot sudheer. it worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding left outer join
 
Similar Threads
Converting a Java Class to XML when Class contains Non-Primitive Types
Query -- select maximum salary in a sum table
Joining tables
Marshalling XML with Spring (How to handle referenced classes)
That's what I meant by tough EJB-QL