NAME

DBIx::DataModel::Schema::ResultAs::Subquery - SQL and bind values in a form suitable for a subquery

SYNOPSIS

# subquery to be used in an IN clause
my $subquery = $source1->select(..., -result_as => 'subquery');
my $rows     = $source2->select(
    -columns => ...,
    -where   => {foo => 123, bar => {-not_in => $subquery}}
 );

# subquery to be used in a SELECT list
my $subquery = $source1->select(..., -result_as => [subquery => 'col3']);
my $rows     = $source2->select(
    -columns => ['col1', 'col2', $subquery, 'col4'],
    -where   => ...
 );

DESCRIPTION

Returns a ref to an arrayref containing \["($sql)", @bind]. This is meant to be passed to a second query, for example through the -in or -not_in operator of SQL::Abstract, or as a column specification in the select list.

When used in the form -result_as => [subquery => $alias], the alias is added as a column alias, following the syntax specified in "column_alias" in SQL::Abstract::More.