I'm starting with DBIx::Class and i have a subselect that wanted to be in DBIx::Class, but i'm getting confused and can't build the code.
My MySQL select is this one:
Select name from tblCategory where id = (
Select id from tblCategory where id = (
Select id from tblRadio where name = "RFM"
)
);
I read that DBIx::Class don't support subselect; is that true? If so, what do you do in situations like this?
According to the DBIx::Class::Manual::Cookbook
there is a new Subquery feature:
my $inside_rs = $schema->resultset('Radio')->search({ name => 'RFM' });
my $rs = $schema->resultset('Category')->search({
id => { '=' => $inside_rs->get_column('id')->as_query },
});
It is marked EXPERIMENTAL so YMMV.
However also note that SQL::Abstract
which DBIx::Class
uses when building its queries does have a new subquery feature using -nest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With