List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:August 20 1999 6:44pm
Subject:Re: SELECT except
View as plain text  
At 14:23, 19990820, toxalot@stripped wrote:
>:-) Thanks.  I was hoping for a way around this, since it is a long list of
>columns.
>
>What I have done was exclude that column when I print, but then I have to
>check for it. If there was a way, it would have been nice to just exclude
>it from the select.

    my $sth;
    $sth = $dbi->prepare("SHOW FIELDS FROM your_table") or
        die "prepare: ", $dbi->errstr;
    $sth->execute or die "execute: ", $sth->errstr;

    my @fields =
        grep { $_ ne 'exclude_column' }
        map { $_->[0] }
        @{ $sth->fetchall_arrayref };

    my $query = "SELECT " . join(', ', @fields) . " FROM your_table";

You could make a subroutine out of this:

    my $field_list = all_fields_except('your_table', 'excl_a', 'excl_b');

Tim

P.S.  Sorry I totally missed what you were asking at first.  :-|
Thread
SELECT excepttoxalot20 Aug
  • Re: SELECT exceptThimble Smith20 Aug
    • Re: SELECT excepttoxalot20 Aug
      • Re: SELECT exceptjeremy brand20 Aug
        • Re: SELECT excepttoxalot20 Aug
          • Re: SELECT exceptThimble Smith20 Aug