我想从全年的数据库中获取结果。
这是查询:
SELECT COUNT(tickets_replay.id) AS amount, users.name,
MONTHNAME(tickets_replay.created) AS month
FROM `tickets_replay` INNER
JOIN users ON tickets_replay.user_id = users.id
WHERE tickets_replay.`created` LIKE '2018%'
AND tickets_replay.`deleted` = '0000-00-00 00:00:00'
AND tickets_replay.comment NOT LIKE
'Uitvoerdatum aangepast naar:%'
AND tickets_replay.comment NOT LIKE
'Status is aangepast naar:%'
AND users.deleted = '0000-00-00 00:00:00'
AND users.id = 21 GROUP BY MONTH(tickets_replay.created)
在我的PhpMyAdmin中,我得到了:
在我的代码中,我得到了回馈:
PHP代码:
$sql_dylan = "
SELECT COUNT(tickets_replay.id) AS amount, users.name,
MONTHNAME(tickets_replay.created) AS month
FROM `tickets_replay` INNER
JOIN users ON tickets_replay.user_id = users.id
WHERE tickets_replay.`created` LIKE '2018%'
AND tickets_replay.`deleted` = '0000-00-00 00:00:00'
AND tickets_replay.comment NOT LIKE
'Uitvoerdatum aangepast naar:%'
AND tickets_replay.comment NOT LIKE
'Status is aangepast naar:%'
AND users.deleted = '0000-00-00 00:00:00'
AND users.id = 21 GROUP BY MONTH(tickets_replay.created)
";
if ($results_dylan = mysqli_query($sql_connect, $sql_dylan)){
while($rows_dylan = mysqli_fetch_assoc($results_dylan)) {
printr($rows_dylan, false);
}
}
function printr($data, $exit = TRUE)
{
if ($data) {
print '<pre>';
print_r($data);
print '</pre>';
}
if ($exit) {
exit;
}
}
我正在使用完全相同的查询,但都没有得到所有结果。 我该如何更改?