in reply to DBI, MAP Help!
First, please read How (Not) To Ask A Question, in particular the section on titles.
This is not a Perl issue, but an SQL issue. You can resolve this by using the IN operator.
As a side note, you should seriously consider using placeholders in your code. It will handle any character escaping that has to be performed and adds a layer of security. As an example, here is how you might form your $sql variable for finding all occurrences in your year array:
my $sql = "SELECT DISTINCT name, email, addr, location FROM my_users WHERE year IN (" . join(', ', ('?') x @year) +. ") "; $i = 0; my $query = $dbh->prepare($dbh) or die "Prepare failure: ".$dbh->errst +r; foreach my $year (@year) { $query->bind_param(++$i,$year); } $query->execute or die "Execute failure: ".$dbh->errstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI, MAP Help!
by runrig (Abbot) on Apr 30, 2009 at 20:28 UTC | |
by kennethk (Abbot) on Apr 30, 2009 at 21:36 UTC |