I am pulling through the latest five entries in a database. I also want to show the total number of entries beside this.
Currently I’m running two queries – the first, to get the latest five:
SELECT reference.id, reference.name
FROM reference
WHERE (status = 2 OR status = 3)
ORDER BY reference.date
LIMIT 5
The second, to count the total:
SELECT COUNT(reference.status) AS complete_count
FROM reference
WHERE (status = 2 OR status = 3)
Is there any way to join these two into one? When I try and add another column to the first query’s output (the COUNT), it only returns one row.
Thanks!
This should give you what you’re hoping for: