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 1:n join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "1:n join" Watch "1:n join" New topic
Author

1:n join

Steve Chernyak
Ranch Hand

Joined: Oct 19, 2000
Posts: 113
I have two tables (Application, Applicant). Every application can have 1 or 2 applicants. Primary key in Application (oid) is the foreign key in Applicant(app_oid). Applicants have different lastnames and SSNs. I would like to allow searching for applications based on lastname or ssn of either applicant. I would also like to do it in one sql statement. Note i need both applicants to comeback in the result set even if only one of theirs (ssn, lastname) matches the requested value.

Thanks
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Join to the Applicant table twice. Once to select both applicants, and again to filter the applications by applicant name.

If it is possible that both applicants could be the same, you might need
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 1:n join
 
Similar Threads
Doubt on table design and Hibernate mapping
Behaviour HashMap
Class conversion to string
Sample SQL question
Dynamic table generation