CRITICAL
Rule Definition
Identify OR conditions testing equality on the same identifier in SQL WHERE clauses:
- one way to improve readability and understandability is to replace them by an IN test condition
- applicable for all sql, including embedded sql
Remediation
Check the statement and if so, replace them by an IN test condition.
Violation Code Sample
The following SQL WHERE clause should be reviewed:
SELECT supplier_name, city, state
FROM suppliers
WHERE supplier_name = 'Microsoft'
OR supplier_name = 'Oracle'
OR supplier_name = 'Flowers Foods';
Fixed Code Sample
Use an IN test condition:
SELECT supplier_name, city, state
FROM suppliers
WHERE supplier_name IN ('Microsoft', 'Oracle', 'Flowers Foods');
Related Technologies
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.