Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Use INFORMATION_SCHEMA tables. – ypercubeᵀᴹ Jan 4 '14 at 12:43
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

share|improve this answer
thanks i got all the values from multiple tables – YLS Jan 24 '14 at 11:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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