in reply to how do i construct a sql select statement, where i want to get the where clauses out of an array
Then loop through the db output withuse DBI; my $dbh = DBI->connect("DBI:mysql:database=your_db"); my $where = "(id = '" . join ("' OR id = '", @ids) . "')"; my $sth = $dbh->prepare("SELECT * FROM event WHERE $where");
NB when @ids is empty your SQL statement is SELECT * FROM event WHERE (id = '') which may be just what you want.while ($ref = $sth->fetchrow_hashref) { &do_stuff_with($ref->{'db_col_u_like'}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how do i construct a sql select statement, where i want to get the where clauses out of an array
by pitbull3000 (Beadle) on Aug 25, 2001 at 21:30 UTC | |
by George_Sherston (Vicar) on Aug 25, 2001 at 21:40 UTC |