![](/img/trans.png)
[英]when I show records from table , sometimes show in records this symbol. I want to understand that why its come sometimes.? i don't want it. �
[英]Why does MySQL query omit records when I want it to show them all?
我正在尝试使用SQL查询输出我的候选表中的所有记录。 它很好地输出了所有记录,直到我添加了INNER JOINs也从由noteID链接的注释表中输出注释数据。
现在,它仅输出附有注释的记录...,但我希望输出包含或不包含注释的所有记录。
try {
$sql = 'SELECT candidate.Firstname, candidate.Lastname, candID, candidate.Email,
date, userID, note, noteID, username
FROM candidate INNER JOIN note ON LastNoteID=noteID INNER JOIN user ON userID=id';
$result = $pdo->query($sql);
}
catch (PDOException $e) {
$error = 'Error fetching candidates: ' . $e->getMessage();
include $errorpage;
exit();
}
while ($row = $result->fetch()) {
$cands[] = array(
'id' => $row['candID'],
'firstname' => $row['Firstname'],
'lastname' => $row['Lastname'],
'email' => $row['Email'],
'noteusername' => $row['username'],
'notedate' => $row['date'],
);
}
如何解决此问题,使其显示候选表中的所有记录(带或不带注释)?
INNER JOIN不包括具有NULL列的行(如您所请求的)。
您是否尝试过使用LEFT JOIN或RIGHT JOIN? 他们会做到这一点,因为它们确实带来了NULL列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.