Number of Subqueries

Previous Next

See Also

Tip

Minimize the number of subqueries in SQL statements.

Example

Rewrite an SQL statement like the following:

SELECT    ...

FROM    Table1

WHERE     ColA =

       ( SELECT T2.ColA    

         FROM     Table2 T2

         WHERE ...)

AND       ColB =

       ( SELECT T2.ColB FROM Table2 T2

         WHERE ...)

to:

SELECT    ...

FROM    Table1

WHERE     (ColA,ColB) =

       ( SELECT T2.ColA, T2.ColB

         FROM Table2 T2

         WHERE ...)