![]() |
Count problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1) +--- Forum: Regional User Groups (https://forum.codeigniter.com/forumdisplay.php?fid=25) +--- Thread: Count problem (/showthread.php?tid=71177) |
Count problem - Germanikus - 07-16-2018 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"); IMG: ![]() RE: Count problem - Pertti - 07-16-2018 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. |