Home

Nested subqueries should be avoided

Rule description

  • Nested subqueries should be avoided

 

Non-compliant Code Example

SELECT
    od.*
FROM
    orders od
Where od.Id in (Select odi.orderId From order_items odi)        --Non compliant code (Nested sub-queries used)

Compliant Code Example

SELECT
    od.*, odi.*
FROM
    orders od
INNER JOIN order_items odi ON           --Compliant code
    odi.order_id = od.order_id
ORDER BY
    od.order_date DESC;
Visual Expert 2020
 VEPLSQLRULE156