Damir Dezeljin wrote:
> Hi again ;)
> 
> 
>>SELECT COUNT(*)
>>  FROM test
>>  WHERE (kid=1) OR (kid=2) OR (kid=4)
>>  GROUP BY cid,aid;
> 
> This query returns:
> +----------+
> | COUNT(*) |
> +----------+
> |        1 |
> |        1 |
> |        2 |
> |        1 |
> |        1 |
> |        1 |
> +----------+
> 6 rows in set (0.03 sec)
> 
> Inest of this I want to get back '6' << so numbers of rows in resulting
> query;
> 
> The same query WITHOUT 'GROUP BY' returns:
> mysql> SELECT COUNT(*) FROM test WHERE (kid=1) OR (kid=2) OR (kid=4);
> +----------+
> | COUNT(*) |
> +----------+
> |        7 |
> +----------+
> 1 row in set (0.00 sec)
> 
> So two rows are grouped because of same cid,did
> 
> Any sugestion?
> 
> Regards,
> Dezo
> 
> 

SELECT COUNT(DISTINCT cid,aid)
  FROM test
  WHERE (kid=1) OR (kid=2) OR (kid=4)

Should give you the number of groups.

Hope this helps
Joseph Bueno


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to