Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

1 Answer 1

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 –  YAY 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.