从数据库中的所有表中选择所有数据并打印到一个表中


Select all data from all tables in a database and print into one table

我的数据库中有50个表。我希望能够从数据库中的所有表中选择所有数据,并将其显示在一个大的html表中。我该怎么做呢?

而不是使用-
($con,"SELECT * FROM table1 ORDER BY date DESC"); x50

我希望能够做这样的事情——($con,"SELECT * FROM table1, table2, table3..... ORDER BY date DESC");然后

echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['time'] . "</td>";

感谢eRIZ的帮助!

使用如图所示的查询不会得到所需的结果:

SELECT * FROM table1, table2, table3...

将返回所有表中所有列的笛卡尔乘积。如果你只想要所有表中的一系列行,你需要一个UNION:

(SELECT * FROM table1)
UNION
(SELECT * FROM table2)
UNION
(SELECT * FROM table3)
...
ORDER BY date DESC;