I'm trying to build a query for the following scenario:
I have two tables Table1 and Table2.
The primary keys of Table1 goes like T1Attr1, T1Attr2 and so on.
Corresponding to each primary key in Table1, I can get a set of attributes from Table2 which goes like T2Attr1, T2Attr2 and so on.
I'm trying to query for the attributes which are common to the attributes of Table1, for example, if the input is T1Attr1 and T1Attr2, the results should have the attributes common to both of them from Table2. As the input parameters grows, the results would be less since common-to-all attributes would be less.
My query is similar to this:
Select indId, indName from indData where pId =1
intersect
Select indId, indName from indData where pId =2
intersect
Select indId, indName from indData where pId =3
The query works fine but when the pId list is huge(above 100), jdbc driver throws an error message.
Can someone please provide suggestions on using this query correctly or provide a better approach for the problem?
Thanks!