in reply to Extracting values from one table and feed the values as a query for second table

Build your second query exactly as you would manually

my $col_clause = join(', ', @names); my $sql = "SELECT ".$col_clause." FROM ..."; my $sth2 = $dbh->prepare($sql) ...

This assumes your column names can only be simple identifiers (no spaces, quotes, commas etc). Incidentally, your table design is almost certainly going to cause you trouble later on. That's a topic for a different forum though.

  • Comment on Re: Extracting values from one table and feed the values as a query for second table
  • Download Code

Replies are listed 'Best First'.
Re^2: Extracting values from one table and feed the values as a query for second table
by eddieson (Initiate) on Aug 26, 2011 at 09:53 UTC

    Thanks loads! It works fine now. Yes I completely agree that the tables are troublesome here, but I don't have permission to change. my task is just to display. Thanks again. <\p>