• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

1:n join

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!