Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

MySQL liefert bei COUNT nur eine Zeile

COUNT() ist eine Aggregatfunktion und liefert ohne GROUP BY nur eine Zeile.

Oft sind zwei Abfragen sinnvoller. Wenn beides benötigt wird:

SELECT *, (SELECT COUNT(*) FROM notis WHERE cid=20) AS count FROM notis WHERE cid=20 ORDER BY nid DESC LIMIT 0,3;