List:General Discussion« Previous MessageNext Message »
From:Mike Seda Date:November 9 2011 1:46am
Subject:Issue With Subqueries
View as plain text  
All,
Can anyone out there explain the result of the third statement provided 
below:

mysql> select count(distinct field1) from db1.table1;
+------------------------+
| count(distinct field1) |
+------------------------+
|                   1063 |
+------------------------+
1 row in set (0.01 sec)

mysql> select count(distinct field1) from db2.table1;
+------------------------+
| count(distinct field1) |
+------------------------+
|                   3516 |
+------------------------+
1 row in set (0.03 sec)

mysql> select count(distinct field1) from db2.table1 where field1 not in 
(select field1 from db1.table1);
+------------------------+
| count(distinct field1) |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.08 sec)

A colleague of mine is stating that the result should be much greater 
than 0.

Please let me know what you think.

Thanks In Advance,
Mike


Thread
Issue With SubqueriesMike Seda9 Nov
  • Re: Issue With SubqueriesMySQL)9 Nov
    • Re: Issue With SubqueriesJavier YĆ©venez9 Nov
      • Re: Issue With SubqueriesJohan De Meersman10 Nov
    • Re: Issue With SubqueriesJohan De Meersman10 Nov
Re: Issue With SubqueriesMike Seda9 Nov