my $field = $old ? "olddata" : "newdata"; $sth = $db->prepare("SELECT * FROM ?"); $sth->execute($field);