Solution 1 is Best and fast: because solution 2 have subquery
BUT you have to change your query like that:
SELECT *, COUNT(*) AS pages
FROM notis
WHERE cid = 20
GROUP BY nid
ORDER BY nid DESC
you changed the place of GROUP BY and ORDER BY.
Idont know if you looking for count(*
) or you want count by every nid
. if count(*
) then consider to not use GROUP BY
SELECT *, COUNT(*) AS pages
FROM notis
WHERE cid = 20
ORDER BY nid DESC