I want to include all tables from a database \"shop\" to mydatabase newshop. I export that \"shop\" database, and now it is named as shop.sql. Is t
Considering this question is tagged with PHP, here's how you could do it:
mysql_query('USE newshop');
$queries = file('shop.sql');
while(list($i, $query) = each($queries)){
$query = trim($query, ';');
if(!empty($query) && $query != 'USE shop'){
@mysql_query($query);
}
}
Make sure "USE shop" in the if statement matches whatever syntax is used in the SQL file. For instance, you might need to make it USE 'shop' or USE schemaname.shop. Or, if there's no USE command in there at all, you can just take that condition right out.