SQL总是返回在大型表上执行的SELECT查询的所有行

When performing the following query on a small test database (100 records), MySQL (phpMyAdmin) returns the number of rows as expected:

SELECT ReportedDate 
FROM table
WHERE ReportedDate IN (
       SELECT ReportedDate  
       FROM table
       GROUP BY ReportedDate  
       HAVING count(*) > 1 
       ORDER BY ugid, ReportedDate
 )

However when I perform the same query on the actual table (1.5 million records), MySQL returns all rows as if it would with a SELECT * FROM table query.

Thank you for any kind of help

Probably your table does not have unique ReportedDate values - they appear in table at least twice each.

Your subquery isn't needed, and with a large data set will impact performance.

Instead of using the subquery and count(*), you might try this:

SELECT ReportedDate  
FROM table
GROUP BY ReportedDate  
HAVING count(DISTINCT ReportedDate) > 1 
ORDER BY ugid, ReportedDate

Notice the distinct in the having clause.