my dog learned polymorphism
The moose likes JDBC and Relational Databases 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "getting reciprocal values from a table" Watch "getting reciprocal values from a table" New topic

getting reciprocal values from a table

Taffy Smith

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?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32818

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
subject: getting reciprocal values from a table
It's not a secret anymore!