eval { $dbh->do(q{drop table if exists newtable}); }; $dbh->do(q{create table newtable select t.time, t.name, t.last, t.company, t.wife from t join p on t.wife = p.wife and t.company = p.company'}); $dbh->disconnect;