in reply to generating various sql arguments dynamically, and on crack

MySQL, at least, supports the IN() clause. For example, I just ran a query:
select title from node where node_id in (1, 2, 3); +----------+ | title | +----------+ | nodetype | | node | | setting | +----------+ 3 rows in set (0.05 sec)
If your database supports that or something similar, you can build a clause resembling and table.column in ('PND', 'NEW').
my %possibleArgs = ( 1 => 'NEW', 4 => 'PND', 9 => 'CLS', ); my @args; for ('col1', 'col2', 'col3') { if (exists($possibleArgs{$_})) { push @args, $possibleArgs{$_}; } } $extraqueryarg = "and table.column in (" . join(',', @args) . ")";
Something similar to that would do the trick.

Replies are listed 'Best First'.
Re: Re: generating various sql arguments dynamically, and bon crack/b
by mr.dunstan (Monk) on Jun 28, 2001 at 03:12 UTC
    Gosh, thanks!

    I had completely forgotten about IN() ... thank you perl monks! Good karma and good health!

    -mr.dunstan