count and groupby together in one query

后端 未结 2 1867
醉话见心
醉话见心 2021-01-29 06:22

The following query is fetching some product info on a page which is fine, but I also want to show the number of the product that it occurs as a text, however, I used grou

相关标签:
2条回答
  • 2021-01-29 06:28

    Your query won't work. Try like this;

     "SELECT pro_id,count(*) FROM cart  WHERE session_id='" . $_SESSION['session'] . "' GROUP BY 
      pro_id  "
    
    0 讨论(0)
  • 2021-01-29 06:50

    Use this query:

    "SELECT pro_id,count(pro_id) FROM cart  WHERE session_id='" . $_SESSION['session'] . "' GROUP BY pro_id  "
    
    0 讨论(0)
提交回复
热议问题