Perl DBIx::Class::ResultSet 个不同的值
Perl DBIx::Class::ResultSet distinct values
您好,我想使用 DBix::Class 从数据库中获取唯一的(不同的)值,但无法使用我当前的搜索方法找到如何做到这一点:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);
感谢您的热心帮助!
您应该可以将第二个散列中的 distinct => 1
添加到 search
函数,例如:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
distinct => 1,
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);
您好,我想使用 DBix::Class 从数据库中获取唯一的(不同的)值,但无法使用我当前的搜索方法找到如何做到这一点:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);
感谢您的热心帮助!
您应该可以将第二个散列中的 distinct => 1
添加到 search
函数,例如:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
distinct => 1,
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);