count() gives 0 but count(distinct) gives 1. is this correct or 
a bug or is there something wrong with my SELECT?

mysql> create table t1 (f1 int);
mysql> insert into t1 values (1);
mysql> create table t2 (f1 int,f2 int);
mysql> select t1.f1,count(t2.f2) from t1
     -> left join t2 on t1.f1=t2.f1 group by t1.f1;
+------+--------------+
| f1   | count(t2.f2) |
+------+--------------+
|    1 |            0 |
+------+--------------+
1 row in set (0.00 sec)

mysql> select t1.f1,count(distinct t2.f2) from t1
     -> left join t2 on t1.f1=t2.f1 group by t1.f1;
+------+-----------------------+
| f1   | count(distinct t2.f2) |
+------+-----------------------+
|    1 |                     1 |
+------+-----------------------+
1 row in set (0.01 sec)

regards,
tommie


---------------------------------------------------------------------
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