Home
SQL EXISTS subqueries should not be used
Rule description
- SQL EXISTS subqueries should not be used
Non-compliant Code Example
SELECT NAME, ADDRESS, CREDIT_LIMIT FROM CUSTOMERS WHERE EXISTS (SELECT NAME FROM VENDOR WHERE NAME IS NOT NULL) --Non compliant code (SQL EXISTS sub-queries is be used)
Compliant Code Example
SELECT NAME, ADDRESS, CREDIT_LIMIT FROM CUSTOMERS INNER JOIN VENDOR ON VENDOR.NAME IS NOT NULL AND VENDOR.NAME = CUSTOMERS.NAME; --Compliant code (SQL EXISTS sub-queries is not used)