我有3张桌子,我试图从列中返回一个列,这让我哭了,为什么它不起作用:
$projectId = 54971033
$id = 53189015
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'
为什么它没有返回什么想法?
答案 0 :(得分:1)
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'