2006 Sep 04 2:34 PM
Hi,
I've a little problem... Let's see if my explanation is clear.
In a program I've 3 select-options, non obligatory. During it's execution, I loop at them and I fill a Range with them to perform a Select (The components of the ranges could be A1, A2, A3).
I made a select which results have SOME of the components of the range. This component is not a key.
This is what I obtain:
ID (key field) Campo1 (compared with the range)
1 A1
2 A2
2 A3
1 A2
1 A3
However, my problem is that what I have to obtain are those registers which key field have ALL the components of the range. Something like that:
ID (Key field) Campo1 (compared in range)
1 A1
1 A2
1 A3
Anyone has a idea of how implement that? It's possible to make it for the internal table that I have or it's better to make a new select?
Thanks for your help,
Oscar
2006 Sep 04 3:10 PM
Use the AND option in your WHERE clase.. ie
SELECT * into table itab
from <dbtab>
where ( campo1 in A1 AND
campo1 in A2 AND
campo1 in A3 ).
~Suresh
2006 Sep 04 3:10 PM
Use the AND option in your WHERE clase.. ie
SELECT * into table itab
from <dbtab>
where ( campo1 in A1 AND
campo1 in A2 AND
campo1 in A3 ).
~Suresh
2006 Sep 04 3:18 PM
Hi, Suresh.
It doesn't work because in this case you're searching values from A1, A2, A3 at the same time at the same record, and they're in different records, so the result of that always is 0 rows.
Thanks for your help,
Oscar
2006 Sep 04 4:09 PM
U can do it in a single query but it might not be that performance effective..but you can try check the same.
SELECT * into table itab
from dtab
where campos in A1
and campos in ( select campos from dtab where campos in A2)
and campos in ( select campos from dtab where campos in A3).