Jump to content

Counting in mysql


Linuus

Recommended Posts

Hi!

 

I'm using Joomla and I need to create a query that counts all rows (articles) in my table that have the same "parent_id" (category). I can do it like this:

 

SELECT COUNT(*) FROM table WHERE parent_id = $my_id

 

and then loop that for every parent_id. There might be many parent_ids so I wonder if I somehow can count everything in one query and then get the data from an array with a loop.

Like use the GROUP by parent_id COUNT(*) as c ....

 

I hope someone understands what I mean. If not, scream and I will try to explain better :)

 

Mysql version: 5.0.67

 

Best regards

Linus

Link to comment
https://forums.phpfreaks.com/topic/193325-counting-in-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.