aspose file tools*
The moose likes JDBC and the fly likes SQL question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL question" Watch "SQL question" New topic
Author

SQL question

Joe Joseph
Greenhorn

Joined: Jun 21, 2006
Posts: 20
Hi,

Suppose i have 4 tables t1, t2, t3, t4.
The below query will fetch me a resultset i am interested in:
Select * from t1, t2, t3, t4 where t1.trade = t2.trade and t2.date = t1.date and t2.trade = t3.trade and t3.date = t1.date and t3.trade = t4.trade and t4.date = t1.date ( i have simplified the conditions in this example here for simplicity sake).
My problem is that i am also interested in finding the orphan records in each table ( ie records with entries missing on the tables for a trade). Note that i cannot use the outer joins here as this might yield me multiple records. How could i proceed with this ?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Joe,
You would need to do this as two queries (or a union of two queries.) The first is the one to find the non-orphaned data, which you have. The second is an outer join with a distinct filter for the orphaned data.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL question
 
Similar Threads
What is the Java equivalent of this C code?
thread overview.
Help in writing a better program for Vampire numbers
Synchronization issue
sequential execution of threads