Re: Incrementing variables based on database data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vinny Gullotta wrote:
Well, what I need to be able to do is then take the numbers of each count and figure out which is used the most. We use this database to log actions taken on servers in our network. What my boss wants me to come up with is a list of which commands are issued the most, which servers get the most attention, and for each server, which command is issued the most, and so I was going to kind of do it messy-like as I'm not really 100% sure of the best way to do it, but my goal was to create the count variables and then compare them using if statements to see which one is used the most. If you have a way of doing this more efficiently, I'd love to hear it. I'm not the best programmer in the world and I'm kind of just getting back into this stuff, so I'm all ears for any suggestions you may have =)

you can do it with one sql query. i don't know the real names of your columns so i'm just going to make some up.

select message_type, count(1) x from table group by message_type order by x desc

you can do the same thing for machines - just change message_type to machine_name.

-jsd-


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux