MySql count() to return 0 if no records found

前端 未结 6 1478
太阳男子
太阳男子 2020-12-17 20:10

I have a set of posts on monthly basis. Now i need an array which contains total records of posts posted in each month. I tried below MySql query, Its working fine, but I wa

6条回答
  •  温柔的废话
    2020-12-17 20:52

    I think you simply need query like this

    SELECT COALESCE(COUNT(id),0) AS totid FROM table
    

    vb example

    Set count=Con.Execute("SELECT COALESCE(COUNT(id),0) AS totid FROM table")
    

    then write

    <%=count("totid")%>
    

提交回复
热议问题