I am using MySQL 5.7 and I have notice something which I cannot explain to myself with my current knowledge so here it goes.
Is an "invalid" date 0000-00-00
considered same as NULL
for a date
column type with no possibilities for nullables? See the following example:
create table if not exists example
(
id int auto_increment primary key,
doskip date default '0000-00-00' not null
);
INSERT INTO example VALUES(1, '0000-00-00'), (2, '0000-00-00'), (3, '0000-00-00');
Having the above and running the following queries gave me the exact same count: 3 and I wonder why, is there any explanation for this?
SELECT COUNT(*) FROM example j WHERE j.doskip = '0000-00-00';
SELECT COUNT(*) FROM example j WHERE j.doskip IS NULL;
Here is a Fiddle showing this behavior, is it because of the mode?