gpt4 book ai didi

php - 使用此内部连接获取数据时遇到问题 (MYSQL/PHP)

转载 作者:行者123 更新时间:2023-11-29 00:30:03 26 4
gpt4 key购买 nike

我有 3 个表,我试图从中返回一个列,这让我哭泣为什么它不起作用:

$projectId = 54971033
$id = 53189015

enter image description here

        SELECT     
iR.author,
i.dateCreated,
i.lastModified,
i.value,
u.username
FROM
informationRelationships iR
INNER JOIN
information i ON
iR.linkId = i.id
INNER JOIN
users u ON
iR.author = u.id
WHERE
iR.contactRef = '$id' AND
iR.projectRef = '$projectId' AND
iR.type = 'Project'

知道为什么它什么都不返回吗?

最佳答案

author 为零,因此请尝试使用 LEFT JOIN:

SELECT     
iR.author,
i.dateCreated,
i.lastModified,
i.value,
u.username
FROM
informationRelationships iR
LEFT JOIN
information i ON
iR.linkId = i.id
LEFT JOIN
users u ON
iR.author = u.id
WHERE
iR.contactRef = '$id' AND
iR.projectRef = '$projectId' AND
iR.type = 'Project'

关于php - 使用此内部连接获取数据时遇到问题 (MYSQL/PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17025894/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com