在一个php页面中使用两个表(mysql) [英] Use two tables in one php page (mysql)
本文介绍了在一个php页面中使用两个表(mysql)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试将所有数据检索到一页上...从这样的一个表中检索数据时,我的工作就很好了:
Trying to retrieve all the data onto one page... I've got this working fine when it's retrieving from one table like so:
$data = mysql_query("SELECT * FROM moduleDetails")
我尝试做
("SELECT * FROM moduleDetails, qResponses")
但这是行不通的,这是我唯一能看到的.
but that doesn't work and is the only thing I can see working.
我听说过使用标识符吗?但是我不太确定如何使用这些...
I've heard about using identifiers? But I'm not quite sure how to use those...
我是PHP的新手,任何提示/示例都很棒.
I am new to PHP, any tips/examples would be great.
推荐答案
SELECT md.*, qr.*
FROM moduleDetails md
LEFT JOIN qResponses qr
ON qr.joinColumn = md.joinColumn
无论您用来将它们链接在一起的任何列,都用作joinColumn.
Whatever column you used to link them together, use as the joinColumn.
这篇关于在一个php页面中使用两个表(mysql)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文