Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Tricky query?
Hi,
Oracle 9205
I have a table:
SQL> select * from ASSETGROUPSMAPPINGS;
ASSETGROUPID ASSETID
------------ ----------
1 1 1 3 1 4 1 6 2 3 2 5
Now I like to have a query which can return a common 'assetgroupid' for a list of 'assetid'. I know it can be done through 'intersect':
SQL> select unique ASSETGROUPID from ASSETGROUPSMAPPINGS where ASSETID =3 intersect select unique ASSETGROUPID from ASSETGROUPSMAPPINGS where ASSETID =5; ASSETGROUPID
2
The problem is that the number of 'assetid' is not fixed, it could be 2, 3, or 6. So it's difficult to implement into our JAVA code.
Any ideas?
Thanks a lot! Received on Thu Aug 26 2004 - 15:32:09 CDT