Welcome Guest, Not a member yet? Register   Sign In
Count problem
#1

Hello everybody,
I'm trying to write a count that tells me it's WHERE.
Was still working.
But if I hit GROUP BY a different number comes out.
As a result, "3" should come

That's the code right now

PHP Code:
   $query02 $this->db->query("SELECT COUNT(warenkorb_wantsUSER_id) anzahl02 FROM warenkorb WHERE warenkorb_havesUSER_id = 3 AND warenkorb.warenkorb_status = 2");
 
   foreach ($query02->result() as $row02){} 

IMG:
[Image: 5m89n2ob.png]
Reply
#2

So you want results for different warenkorb_havesUSER_id users, instead of just warenkorb_havesUSER_id = 3?

Code:
SELECT warenkorb_havesUSER_id, COUNT(warenkorb_havesUSER_id) AS anzahl02 FROM warenkorb WHERE warenkorb_status = 2 GROUP BY warenkorb_havesUSER_id

This will return different warenkorb_havesUSER_id's with related row counts.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB