skip to Main Content

If I run SELECT * FROM table; on one of my tables, I get 87709 rows.

If I instead run SELECT * FROM table WHERE isDeleted = 0 OR isDeleted = 1; on the same table, I get 87686 rows.

isDeleted only has the values of 0 or 1, which I have confirmed with SELECT DISTINCT isDeleted FROM table;

Where have the 23 missing rows gone?


ANSWER:

Thx Roland Aaronson for pointing out that phpMyAdmins “count” is not as accurate as COUNT(*).

Did SELECT COUNT(*) FROM table; and SELECT COUNT(*) FROM table WHERE isDeleted = 0 OR isDeleted = 1; which gave the same amount of rows! *YAY*

3

Answers


  1. run this query SELECT * FROM table WHERE isDeleted ISNULL, then you will rows with the null. If it has 23 rows, that’s where the problem lies

    Login or Signup to reply.
  2. Try:

    SELECT isDeleted, COUNT(*) from table GROUP BY isDeleted;
    

    If you want to get an accurate count and all the distinct values. I am guessing your “count” might be what something like phpMyAdmin is showing, which may not be accurate.

    Login or Signup to reply.
  3. You could confirm the values is not null by

    SELECT * FROM table WHERE isDeleted IS NOT NULL

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search