1

我有 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'                    

任何想法为什么它什么都不返回?

4

1 回答 1

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' 
于 2013-06-10T14:13:18.383 回答