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

编程入门 行业动态 更新时间:2024-10-26 16:29:26
本文介绍了在一个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)

本文发布于:2023-10-30 12:10:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   页面   php   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!