Like others have said it would be easier with a better idea of what it is you would like to do. Maybe just explain what you would like to accomplish. That said, i guessed that you meant you want to find " all elements in MYTABLE where num1 is in the set @array_num and num2 = some value." The solution to that problem is as below. You want to use the the ? placeholder because its a realy good idea. So i generate an IN statment using the lenght of @array_num to create the correct number of ?. Then prepare and execute the query.
my @array_num = (123, 456, 345, 459, 234); my $sql = 'SELECT tb.num1, tb.num2 FROM MYTABLE tb WHERE tb.num1 IN (' + . join(',', ('?') x @array_num) . ') AND tb.num2=?'; my $select = $dbi->prepare($sql); $select->execute(@array_num, $n2);
This generates the sql statment SELECT tb.num1, tb.num2 FROM MYTABLE tb WHERE tb.num1 IN (?,?,?,?,?) AND tb.num2=? and fills in the ? with the correct values.
In reply to Re: Array, SQL Question!
by eric256
in thread Array, SQL Question!
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |