[英]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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.