Now DBI will die with $DBI::errstr for you.my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError=>1});
Onward ... so, what you want is to select the rows whose fields ALL do not contain the token 'NA'. You can do this with SQL, if you don't mind a lot of appended comparisons:
There, no Perl code needed. But, since you asked ... here is one way to do it:SELECT MID,Mname FROM ML_Lists WHERE MID != 'NA' OR ML_Lists != 'NA'
grep is used to find the number of fields that contain only the string 'NA' and that number is compared to the total number of rows (@$_ in this context) to see if they are the same. If they are not, then the row contains at least one field that does not have the value 'NA', and that row is pushed to @list. (Personally, i'd rather let the database handle this job, not Perl.)my @list; my $sth = $dbh->selectall_arrayref('select MID,Mname from ML_Lists'); for (@$sth) { push @list,$_ if grep(/^NA$/,@$_) != @$_; }
Hope this helps, and if you haven't already, then please check out The fine art of database programming. Purchasing Programming the Perl DBI isn't a bad idea either (considering you read it, of course). Hope this helps. :)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: CGI Table Column Selection
by jeffa
in thread CGI Table Column Selection
by devslashneil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |