我正在开发我的 PHP 应用程序,但这个查询有问题:
SELECT imagesets.id, imagesets.name, users.name AS username, users.email, COUNT(images.id) AS count
FROM fotosite.imagesets
INNER JOIN users ON imagesets.userid = users.id
INNER JOIN images ON imagesets.id = images.imageset
GROUP BY imagesets.id
ORDER BY imagesets.id desc;
images
但是,如果表中没有与给定 ID 匹配的数据,则该查询不会返回结果。
例如,此查询工作正常,但没有给我我想要的计数列:
SELECT imagesets.id, imagesets.name, users.name AS username, users.email
FROM fotosite.imagesets
INNER JOIN users ON imagesets.userid = users.id
GROUP BY imagesets.id
ORDER BY imagesets.id desc;