I have a table with three columns: taxon_id, scientific_name_element_id, and parent_id. I want to find the elements that are children and not parents, so the termini of the structure.
I found some sources that suggested that I use
select taxon_id
from taxon_name_element
where taxon_id not in
(select parent_id from taxon_name_element)
But this does not work, I get an empty set when I can actually browse the entries and see that there is, for example, a taxon_id=1, and NO parent_id=1
Conversely when I see what taxon_id's are in parent_id's I get a nonempty result set
What am I doing wrong? How can I fix this?
3 <> NULLis indeterminate, because theNULLmight be a three; so, too, is3 NOT IN (1, 2, NULL). MySQL will only return rows that are known to satisfy theWHEREclause.