Yes, a counter is an aggregate statement that returns only one row (without a group by clause)
Maybe make two separate requests? It does not make sense for a row to return data and the total number of rows, because this data does not belong to each other.
If you really want this, you can do something like this:
SELECT *, (select count(*) FROM notis WHERE cid=20) AS count FROM notis WHERE cid=20 ORDER BY nid DESC LIMIT 0,3
or that:
SELECT N.*, C.total from notis N join (select count(*) total FROM notis WHERE cid=20) C WHERE cid=20) AS count FROM notis WHERE cid=20 ORDER BY nid DESC LIMIT 0,3
With deviations of the nested expression depending on your SQL dialect.
Mckay
source share