2008 Dec 18 8:18 AM
Hi ,
I need to write a select query which involves the selection of multiple values for the same field .
eg. I need to select the rows from a table which have field 'object' the values a and b and c ?
Is the following select query valid?
SELECT * FROM table INTO s_table WHERE object = 'a' and 'b' and 'c'.
2008 Dec 18 8:20 AM
SELECT * FROM table INTO s_table WHERE object in ( 'a' 'b' 'c').
regards
Kiran
2008 Dec 18 8:20 AM
SELECT * FROM table INTO s_table WHERE object in ( 'a' 'b' 'c').
regards
Kiran
2008 Dec 18 8:20 AM
SELECT * FROM table INTO s_table WHERE object = 'a' or object = 'b' or object = 'c'.
2008 Dec 18 8:20 AM
Hi
SELECT * FROM table INTO s_table WHERE
object = 'a' or
object = 'b'
or object = 'c'.
Regards
Aditya
2008 Dec 18 8:22 AM
Hi,
Write the select quiry as below.
SELECT * FROM table INTO s_table WHERE object IN ( 'a' , 'b', 'c' ).
Regards,
Murthy.
2008 Dec 18 8:26 AM
Thanks for your answers..
But I want to select an object which neccesarily has all the three value (i.e. a and b and c assigned to it.)
2008 Dec 18 8:28 AM
Hi
Is it possible that for a single record OBJECT is having all 3 different values
Regards
Aditya
2008 Dec 18 8:30 AM
Hi,
Select * from sflight into table itab where carrid = 'AA' or
carrid = 'LH' OR CARRID = 'UA'.
IF SY-subrc is initial.
endif.
Best Regards
Ramchander Rao.K
2008 Dec 18 8:32 AM
Hi Aditya,
The same object can have different value for differnt records.
But for a single record , it only has one value.
Thanks.
2008 Dec 18 8:39 AM
Hi,
So the object has different values for different records.
then this id wat you can do.
SELECT * FROM table INTO s_table WHERE object IN ( 'a','b','c').
Regards,
Manoj Kumar P
2008 Dec 18 8:40 AM
Hi,
IF you use like this you can't get.
do like this, i hope it will be help full.
Select * from table inti s_tbale where object = 'a', or object = 'b' or object = 'c'.
then in your s_table will have all the records comes under a , b and c.
then depeding on condition loop it.
Regards,
Arjun.
2008 Dec 18 9:16 AM
For your particular requirement it may not be possible to get a result set from query itself.
Fetch your data as suggested above using .. WHERE object IN ('a','b','c')
After this loop on your itab. For each record you should check if there is a corresponding record for object 'b' and 'c'.
Sample could be:
LOOP at itab where object = 'a'..
READ itab with key object = 'c' and ..other key fields
READ itab with key object = 'b' and ..other key fields
IF both return sy-subrc 0 then continue else delete.
ENDLOOP.