Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Filtering Results...

Former Member
0 Likes
508

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

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
475

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

3 REPLIES 3
Read only

suresh_datti
Active Contributor
0 Likes
476

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

Read only

0 Likes
475

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

Read only

0 Likes
475

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).