SQL query to select only grandchildren

后端 未结 5 1459
无人及你
无人及你 2021-01-12 16:04

I\'m pretty new to SQL, trying to wrap my head around it, but it\'s getting a little confusing. Here\'s a simplified version of what I\'m working with.

I have this

5条回答
  •  感情败类
    2021-01-12 16:18

    To get the grandchildren, Try this query.

    SELECT name FROM people WHERE parent_id IN (SELECT id from people where parent_id >0);
    

提交回复
热议问题