How to get all the tables from database with all values in tables using single query.. I tried using

$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);
$arrayCount = 0
while ($row = mysql_fetch_row($result)) {
$tableNames[$arrayCount] = $row[0];
$arrayCount++; //only do this to make sure it starts at index 0
foreach ($tableNames as &$name {
$query = "INSERT INTO metadata (table_name) VALUES ('".$name."')";

but it gives me only tables name

  • Use INFORMATION_SCHEMA tables. – ypercubeᵀᴹ Jan 4 '14 at 12:43
  • 1
    What are you actually trying to accomplish, here? – Michael - sqlbot Jan 5 '14 at 1:02
  • this question could be moved to stackoverflow because this is an PHP... – Raymond Nijland Jan 5 '14 at 17:51

Use the information_schema.columns table


select table_name,column_name from information_schema.columns


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.