I don't know how does MySQL works internally, but I'm sure there are some problem with indexes or some metainformation about table counts:
mysql> select count(*) from Event;
+----------+
| count(*) |
+----------+
| 5925 |
+----------+
1 row in set (0,01 sec)
mysql> select count(*) from Event where event_id in (select discount_event_id from Discount);
+----------+
| count(*) |
+----------+
| 5901 |
+----------+
1 row in set (0,12 sec)
mysql> select count(*) from Event where event_id not in (select discount_event_id from Discount);
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0,11 sec)
These 24
missing event_id
s makes no sense. It's just logically impossible from my point of view. There cannot be 24
rows that both are and aren't in another set. Or they are, or they aren't.
Also, as suggested from some of the answers and comments, there are no NULL
event_id
s, since these are the rowids:
mysql> select count(*) from Event where event_id is null;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
What is going on?