This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes getting reciprocal values from a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getting reciprocal values from a table" Watch "getting reciprocal values from a table" New topic
Author

getting reciprocal values from a table

Taffy Smith
Greenhorn

Joined: Jun 29, 2009
Posts: 1
Hi everyone,

Is there a way I can write an sql query to return reciprocal values from a single table?

for example, if I have the following rows:



can I write a sql query that will return the first, and last row, since they have a reciprocal relationship? Or would I need to use a stored procedure with a cursor to loop through them all?

Thanks,
Taf
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

Taf,
How about doing a join (cartesian join that matches all of them) and see which come to the same value when diving a/b?


[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
 
 
subject: getting reciprocal values from a table
 
Similar Threads
inner join Vs outer join
need help with design of a Login page in JSP
Regarding apply JOIN by using JPQL.
DB2 700 and 701 - Test Sample
JPA native query, group function, different entity