I would suggest that tbl_1.clean_deep_link
is NULL
for the rest of the lines.
These values โโare not IN
and NOT IN
your subquery.
Another reason may be that you have NULL
in tbl_2.clean_deep_link
.
Try the following:
select count(1) from tbl_1 where clean_deep_link not in (select clean_deep_link from tbl_2 WHERE clean_deep_link IS NOT NULL);
The problem with NULL
is that it is neither =
nor <>
any other value (including NULL
).
When checking NOT IN
MySQL must check each value in tbl_1
that it is not contained in tbl_2
and thus checks if they are <>
.
Your values โโwere not <> NULL
, so they were not NOT IN
.
See also: Using the NOT IN operator with null values
Check out the example in SQL Fiddle .
source share