I has very strange situation with MySQL. I have 2 tables. First table has column ID (primary key) and has ~560 000 rows. Second table has column IDBook (rows from first table from ID column) and has ~259 000 rows.
If I try to try search from first table
SELECT * FROM testovoe_zadanie_poisk_knig.book
where id=66764
then one row returned.
If I try to try search from second table
SELECT * FROM testovoe_zadanie_poisk_knig.autors
where IDBook=66764
then 0 rows returned.
It's OK.
But. If I execute SQL script
SELECT count(b1.id) FROM testovoe_zadanie_poisk_knig.book b1
where b1.id not in (
select IDBook
from `testovoe_zadanie_poisk_knig`.`autors`
)
then returned 0.
Why?