package My::Schema::User; use base qw/DBIx::Class/; # ->load_components, ->table, ->add_columns, etc. # Make a new ResultSource based on the User class my $source = __PACKAGE__->result_source_instance(); my $new_source = $source->new( $source ); $new_source->source_name( 'UserFriendsComplex' ); # Hand in your query as a scalar reference # It will be added as a sub-select after FROM, # so pay attention to the surrounding brackets! $new_source->name( \<register_source( 'UserFriendsComplex' => $new_source ); Next, you can execute your complex query using bind parameters like this: my $friends = [ $schema->resultset( 'UserFriendsComplex' )->search( {}, { bind => [ 12345, 12345 ] } ) ]; ... and you'll get back a perfect L.