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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Query Preparation" Watch "Query Preparation" New topic
Author

Query Preparation

Sameer Kumar
Greenhorn

Joined: Jul 09, 2008
Posts: 6
Hi All,

ID A B
1 200 500
2 100 300
3 555 666
4 666 555

5 541 256
6 454 45454
7 5656 122

I have a table with the sample data mentioned above.
I need to find the records where there is a circular reference between coloumns A and B.
For ex: record 3 & 4 refers to each other.
3 555 666
4 666 555

Can any one help me out how we can prepare this query.

Regards,
Sameer


Regards,<br />Sameer Kumar
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

select A,B from tbl t1 where exists (select 'X' from tbl t2 where t2.a = t1.b and t2.b = t1.a) ? Not sure.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query Preparation