Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Using combination of "AND" and "OR" in SELECT in ABAP
You can combine AND and OR operators in ABAP SELECT statements to create complex filtering conditions. This allows you to specify multiple criteria that must be met simultaneously while also providing alternative options for certain fields.
Using AND with OR in Parentheses
You can use the following query to combine conditions ?
SELECT * FROM my_table WHERE condition_1 AND condition_2 AND ( id EQ '2' OR id EQ '3' ).
Note: There should be space after and before the bracket for proper syntax formatting.
In this example, both condition_1 and condition_2 must be true, AND the id field must equal either '2' OR '3'.
Alternative Using IN Statement
Alternatively, you can use the IN statement which is more efficient when checking multiple values for the same field ?
SELECT * FROM my_table WHERE condition_1 AND condition_2 AND id IN ( '2', '3' ).
The IN operator is functionally equivalent to using multiple OR conditions but provides better readability and performance when checking a single field against multiple values.
Conclusion
Combining AND and OR operators in ABAP SELECT statements provides flexible data filtering capabilities, while the IN operator offers a cleaner alternative for multiple value comparisons on the same field.
