I need to execute this query and change the name of the table

$table1 = 'tab1';
$table2 = 'tab2';
$data1 = 'a';
$data2 = 'b';

my $sth = $dbh->prepare(qq|SELECT count(id) FROM ? WHERE data1=? |);

$sth->execute( $table1,$field1 );
$total1=$sth->fetchrow_array();

$sth->execute( $table2,$field2 );
$total2=$sth->fetchrow_array();

but the error is:

DBD::mysql::st execute failed: You have an error in your SQL syntax near
''tab1' WHERE data='a'' at line 1

What's wrong ?

Can I make a placeholder for the name of the table ?

Thanks

david



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to