简体   繁体   English

在一个php页面中使用两个表(mysql)

[英]Use two tables in one php page (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") 

I've tried doing 我试过了

("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... 但我不太确定如何使用这些......

I am new to PHP, any tips/examples would be great. 我是PHP的新手,任何提示/示例都会很棒。

SELECT md.*, qr.*
FROM moduleDetails md
LEFT JOIN qResponses qr
ON qr.joinColumn = md.joinColumn

Whatever column you used to link them together, use as the joinColumn. 无论您使用哪个列将它们链接在一起,都可以用作joinColumn。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM