DISQUS

Code Spatter: Conditions on Count or Sum in MySQL

  • Kuroki Kaze · 1 year ago
    Thanks, useful.
  • Luciano · 1 year ago
    It's a good tip, thanks.
  • suresh vijayan · 1 year ago
    hi
    myself suresh...a great programmer...if anybody needs help..just mail to me.
  • buellart · 4 months ago
    ah, thanx Greg, that gave me a kick in the back!
  • jarnail · 3 months ago
    Can we do count and sum in single SQL?

    I have a table where i need SUM of a field as will as I have to COUNT total effected rows.

    Any idea?
  • jarnail · 3 months ago
    Hello

    I just did it.

    I used this:
    SELECT count(products_id) as count_products , SUM( reviews_rating ) as total FROM TABLE WHERE products_id=".$product_id;
  • Greg Allard · 3 months ago
    yeah that looks like it should work