Welcome Guest, Not a member yet? Register   Sign In
how to access the count(*) property?
#15

[eluser]jmadsen[/eluser]
If you mix an aggregate (Count(), Sum(), Max(), etc. ) with non-aggregate fields (name, address, etc) such as this:

$row = $this->db->select('count(*), name, address, telephone')

Then you MUST use a GROUP BY.

If you are grouping, it's a good bet (not always) that you are prepared for more than one group. So num_rows() is not correct to use here.

---

In addition, the real problem here was that the poster did not know that he should alias calculated rows of any sort, and reference them.

That's what people should learn from this post.


Messages In This Thread
how to access the count(*) property? - by El Forum - 01-21-2010, 11:45 PM
how to access the count(*) property? - by El Forum - 01-22-2010, 12:25 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 12:53 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 12:56 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 12:58 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 03:33 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 04:02 AM
how to access the count(*) property? - by El Forum - 01-22-2010, 07:09 AM
how to access the count(*) property? - by El Forum - 01-28-2010, 08:40 PM
how to access the count(*) property? - by El Forum - 01-28-2010, 09:11 PM
how to access the count(*) property? - by El Forum - 01-28-2010, 09:58 PM
how to access the count(*) property? - by El Forum - 01-29-2010, 12:31 AM
how to access the count(*) property? - by El Forum - 01-29-2010, 03:35 AM
how to access the count(*) property? - by El Forum - 01-29-2010, 04:18 AM
how to access the count(*) property? - by El Forum - 02-07-2010, 06:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB