subq

Description

Identifies a subquery.

Syntax

( subq subquery_id
             )

Parameters

subquery_id

is an integer identifying the subquery. In abstract plans, subquery numbering is based on the order of the leading parenthesis for the subqueries in a query.

Examples

Example 1

select c11 from t1
where c12 = 
        (select c21 from t2 where c22 = t1.c11)

( nested 
        ( t_scan t1 ) 
        ( subq 1 
                ( t_scan ( table t2 ( in ( subq 1 ) ) ) ) 
        ) 
)

A single nested subquery.

Example 2

select c11 from t1
where c12 = 
        (select c21 from t2 where c22 = t1.c11)
    and c12 = 
        (select c31 from t3 where c32 = t1.c11)

( nested 
        ( nested 
                ( t_scan t1 ) 
                ( subq 1 
                        ( t_scan ( table t2 ( in ( subq 1 ) ) ) ) 
                ) 
        ) 
        ( subq 2 
                ( t_scan ( table t3 ( in ( subq 2 ) ) ) ) 
        ) 
) 

The two subqueries are both nested in the main query.

Example 3

select c11 from t1
where c12 = 
    (select c21 from t2 where c22 = 
        (select c31 from t3 where c32 = t1.c11))

( nested 
     ( t_scan t1 ) 
     ( subq 1 
          ( nested 
               ( t_scan ( table t2 ( in ( subq 1 ) ) ) ) 
               ( subq 2 
                    ( t_scan ( table t3 ( in ( subq 2 ) ) ) ) 
               ) 
          ) 
     ) 
) 

A level 2 subquery nested into a level 1 subquery nested in the main query.

Usage

See also

in, nested, table