[PHP-DB] Getting total quantities

2010-02-14 Thread Karl DeSaulniers
Hello List, I have a situation where I want to figure out the total number of products in my database. I want to read all the fields $ProductStock and add them together to get the TOTAL number of products, not just the number of rows in my database. Any pointers on the code to use for

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Karl DeSaulniers
Would it be? $q = SUM(ProductStock) FROM products; or $q = SELECT SUM(ProductStock) AS ProductStock FROM products; if I want to return $ProductStock as the value? Karl On Feb 14, 2010, at 10:55 PM, Karl DeSaulniers wrote: Hello List, I have a situation where I want to figure out the

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Chaitanya Yanamadala
Have you tried using it like this *select count(*) from products;* Chaitanya A man can get discouraged many times but he is not a failure until he stops trying... On Mon, Feb 15, 2010 at 10:39 AM, Karl DeSaulniers k...@designdrumm.comwrote: Would it be? $q = SUM(ProductStock) FROM

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Chris
Karl DeSaulniers wrote: Would it be? $q = SUM(ProductStock) FROM products; or $q = SELECT SUM(ProductStock) AS ProductStock FROM products; if I want to return $ProductStock as the value? This one. The AS gives it an alias (or shortcut) to make it easier to find in mysql_fetch_array etc.

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Chris
Chaitanya Yanamadala wrote: Have you tried using it like this *select count(*) from products;* This will give you the number of rows in the table, not what Karl wants. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Chaitanya Yanamadala
*Hai Chris I already send him the right one. But my mail has been blocked by the php lists. so i send a personal mail for him... FYI SELECT SUM(ProductStock) FROM products; * if u want to give an other name for the row then use it as * ** SELECT SUM(ProductStock) as stock FROM products;*

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Karl DeSaulniers
Ok, sweet, then I am on the right track. Now I did notice that I forgot the SELECT in the first query, does that matter? Can I just start out with SUM? Thanks for your response. Karl On Feb 14, 2010, at 11:32 PM, Chris wrote: Karl DeSaulniers wrote: Would it be? $q = SUM(ProductStock)

Re: [PHP-DB] Getting total quantities

2010-02-14 Thread Chris
Karl DeSaulniers wrote: Ok, sweet, then I am on the right track. Now I did notice that I forgot the SELECT in the first query, does that matter? Can I just start out with SUM? No - that's invalid sql. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List