![](/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.