I think over other problem.
In the table (shown below) there is another column defined as timestamp(6).
Do you think is it possible to get result grupped by month period: form
january  to december ??

Best regards,

Paul



id | product | dat
-------------------
0 | switch   | 030702
1 | switch   | 031214
2 | hub       | 031215
3 | hub       | 031217
4 | hub       | 031218


----- Original Message ----- 
From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: "Pawel Filutowski" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, December 15, 2003 1:53 PM
Subject: RE: Haw to get specific result?


[snip]
id | product
------------
0 | switch
1 | switch
2 | hub
3 | hub
4 | hub
5 | wire
6 | wire
7 | wire
8 | wire
9 | wire
.
.
I`m looking for query which give me result as array:
0 - > count of 'switch'
1 - > count of 'hub'
2 - > count of 'wire'
[/snip]

SELECT COUNT(product), product FROM table GROUP BY product;

Now, this doesn't give you an array, but you can use this query to
populate an array in the programming language that you are using, such
as PHP...

$sql = "SELECT COUNT(`product`), `product` FROM `table` GROUP BY
`product`" ;
if(!($result = mysql_query($sql, $connection_string))){
   echo "MySQL Error: " . mysql_error() . "\n";
   exit();
}
$sqlArray = mysql_fetch_array($result); // returns a one row array, just
loop through to access all rows

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to