sub genWhereString {
my ($fields, $where, $orderby) = @_;
my $query = "select " . join(", ", @$fields);
$query .= " " . join(" and ", @$where) if $where;
$query .= $orderby if $orderby;
my $sth = $dbh->prepare($query) || return $DBI::errstr;
# et cetera
####
my @a = (1 .. 10);
my @b = (1 .. 3);
@a = @b;
####
my @a = (1 .. 10);
@a = (1 .. 5);
####
my @a = (1 .. 10);
@a = 1;
####
my @a = (1 .. 10);
@a = some_sub_returning_one_or_more_results();