使用php mysql从五个表中选择
我有五张桌子:
在这些表格中,一个字段很常见,即name
。
SELECT *
FROM table1, table2, table3, table4, table5
WHERE table1.name = table2.name
and table2.name = table3.name
and table3.name = table4.name
and table4.name = table5.name
这种查询应该工作吗?
试试这个例子,并根据自己的喜好调整它。
SELECT T1.*, T2.*, T3.*, T4.*, T5.*
FROM TABLE1 T1
JOIN TABLE2 T2 ON T1.NAME = T2.NAME
JOIN TABLE2 T3 ON T1.NAME = T3.NAME
JOIN TABLE2 T4 ON T1.NAME = T4.NAME
JOIN TABLE2 T5 ON T1.NAME = T5.NAME
链接地址: http://www.djcxy.com/p/94301.html