Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show all the tables from multiple databases

How to select all the tables from multiple databases in mySql.. I am doing the following steps but not able to achive the goal.

<?php
$a = "SHOW DATABASES";
$da = $wpdb->get_results($a);

foreach($da as $k){
echo '<pre>';
print_r ($k->Database);//prints all the available databases
echo '</pre>';
$nq = "USE $k->Database";//trying to select the individual database
$newda = $wpdb->get_results($nq);
$alld = "SELECT * FROM $k->Database";
$td = $wpdb->get_results($alld);
var_dump($td);//returns empty array
}
?>

Please Help me

like image 859
Soarabh Avatar asked Jun 12 '10 07:06

Soarabh


1 Answers

Use the INFORMATION_SCHEMA:

select table_schema, table_name from information_schema.tables;
like image 130
cherouvim Avatar answered Oct 17 '22 17:10

cherouvim