¿Hay valores NULL en taxon_name_element.parent_id
? ?
La consulta...
select taxon_id
from taxon_name_element
where taxon_id not in (
select parent_id
from taxon_name_element
)
...es equivalente a...
select taxon_id
from taxon_name_element
where
taxon_id <> parent_id_1
AND taxon_id <> parent_id_2
...
AND taxon_id <> parent_id_N
...donde parent_id_X
son valores reales que están actualmente en el parent_id
columna. Si incluso uno de ellos es NULL, el correspondiente taxon_id <> parent_id_X
las expresiones se "colapsarán" en NULL, arrastrando toda la expresión WHERE con ella.
Filtre los valores NULL para obtener lo que desea:
select taxon_id
from taxon_name_element
where taxon_id not in (
select parent_id
from taxon_name_element
where parent_id is not null
)