Mysql returns only one row when using Count

前端 未结 3 1332
深忆病人
深忆病人 2020-12-10 14:38

Well I\'ve just hit a weird behaviour that I\'ve never seen before, or haven\'t noticed.

I\'m using this query:

  SELECT *, 
         COUNT(*) AS pag         


        
3条回答
  •  不知归路
    2020-12-10 15:03

    Using an aggregate function without a GROUP BY will always return one row, no matter what. You must use a GROUP BY if you want to return more than one row.

    Note that on most RDBMS, such a query would have failed because it makes no sense.

提交回复
热议问题