ForeignKey Referencing Same Table

后端 未结 5 1617
栀梦
栀梦 2021-02-05 22:08

There was an interview test in which below was the table and structure

 Table Person = id, name, dob, dod, mother_id, father_id
 Primary Key (id)
 Foreign Key mo         


        
5条回答
  •  花落未央
    2021-02-05 22:36

    SELECT * 
    FROM Person 
    WHERE father_id = (SELECT id FROM Person WHERE name = 'John Smith')
    AND    mother_id = (SELECT id FROM Person WHERE name = 'Jane')
    

提交回复
热议问题