Bug #29685 SELECT with EXISTS and GROUP BY gives wrong result
Submitted: 10 Jul 2007 9:40 Modified: 10 Jul 2007 11:38
Reporter: Daniel Penning Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:>=5.0.40 OS:Any
Assigned to: CPU Architecture:Any

[10 Jul 2007 9:40] Daniel Penning
Description:
Some grouped queries with an EXISTS condition deliver an empty resultset under MySQL 5.0.40. Older Versions return the expected result. (checked on 5.0.20 and 5.0.37)

How to repeat:
mysql> SELECT VERSION();
+---------------------+
| VERSION()           |
+---------------------+
| 5.0.41-community-nt |
+---------------------+
1 row in set (0.00 sec)

mysql> CREATE TABLE test (a tinyint default 0 NOT NULL, b tinyint default 0 NOT NULL);
Query OK, 0 rows affected (0.05 sec)

mysql> INSERT INTO test(a,b) VALUES (1,1),(2,2);
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM test t1 WHERE EXISTS(SELECT * FROM test t2 WHERE t2.a=t1.a) GROUP BY t1.a;
Empty set (0.00 sec)
[10 Jul 2007 9:56] Sveta Smirnova
Thank you for the report.

I can not repeat described behaviour with current development sources, although bug is repeatable with version 5.0.41. Please wait next release.
[10 Jul 2007 11:38] MySQL Verification Team
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html