MySQL “NOT IN” query not working

前端 未结 2 2061
自闭症患者
自闭症患者 2020-12-11 08:57

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

2条回答
  •  甜味超标
    2020-12-11 09:44

    Assuming the parent_id column is NULL (meaning no value is set)

    To select all scientific_name_element_id that have no value for parent_id (meaning parent_id is NULL)

    You do this:

    SELECT scientific_name_element_id
    FROM YOUR_TABLE
    WHERE parent_id IS NULL
    

    This will get you a list of scientific_name_element_id that have no parents.

提交回复
热议问题