Would your solution to this be have huge if/elsif statement . . .
No, I'd put the columns I wanted for each table in an HoA:
my %COLUMNS = ( MY_FIRST_TABLE => [ qw( blah_1 blah_2 ) ], MY_2ND_TABLE => [ qw( another_col dob ) ], . . . ); # $table defined elsewhere my $SQL = 'SELECT ' . join(',', @{ $COLUMNS{$table} }) . " FROM $table +";
Clean, efficient, no SELECT *.
Update: Added some missing whitespace in the SQL generated.
. . . describe table (which BTW is not portable to other DBMSs) . . .
MySQL's describe table isn't, but DBI's column_info method is. (Though I wouldn't use that particular solution).
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
In reply to Re: Re: Re: Re: Re: selecting again from a mysql database
by hardburn
in thread selecting again from a mysql database
by bory
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |