use strict; use SQL::Abstract; my @all_names = qw/one two three/; my @email = qw/first_email second_email third_email/; my @local = qw/here there and_everywhere/; my @year = qw/1970 1980 1990/; my @order = qw/location name/; my $sql = SQL::Abstract->new; my @fields = qw/name email addr location/; my $table = 'my_users'; my %where = ( year => \@year, email => \@email, location => \@local, name => \@all_names, ); my ( $stmt, @bind ) = $sql->select( $table, \@fields, \%where, \@order ); print "$stmt\n"; print join '|', @bind; #### SELECT name, email, addr, location FROM my_users WHERE ( ( ( email = ? OR email = ? OR email = ? ) AND ( location = ? OR location = ? OR location = ? ) AND ( name = ? OR name = ? OR name = ? ) AND ( year = ? OR year = ? OR year = ? ) ) ) ORDER BY location, name first_email|second_email|third_email| here|there|and_everywhere| one|two|three| 1970|1980|1990 #### my $sth = $dbh->prepare($stmt); $sth->execute(@bind);