- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
create table test(
id integer primary key auto_increment,
d datetime not null
);
insert into test(id) values (1);
-- а сейчас я покажу вам особую уличную магию
select *, d is null, d is not null from test;
select *, d is null, d is not null from test
where d is not null;
select *, d is null, d is not null from test
where d is null; -- WTF?!
select *, d is null, d is not null from test
where d is not null and d is null; -- WTF?!
Все 4 select'а выводят одинаковый результат... MySQL такой MySQL...
P.S. Вставка всякой херни вместо вывода ошибки лечится добавлением STRICT_ALL_TABLES в sql_mode. А вот where с нулевой датой не лечится, видимо, это баг движка.