SQLite Forum

Find the relation in a sql query
Login
Hi,

I have this table that gives the names of the father and the children:

| id | names    |
|----|----------|
| 1  | Frank    |
| 2  | Gabriel  |
| 3  | Geoffrey |
| 4  | George   |
| 5  | Gordon   |
| 6  | Heather  |

This second table tells who the children of each parent are, for example Geoffrey and Gabriel are Frank's children, and George, Gordon and Heather are Geoffrey's children:

| id | id_parente | id_child |
|----|------------|----------|
| 1  | 1          | 2        |
| 2  | 1          | 3        |
| 3  | 3          | 4        |
| 4  | 3          | 5        |
| 5  | 3          | 6        |

I have tried in various ways to find a way to make a query that gives me the name of the father given the name of one or more children, for example if they give me George and Gordon the query should give me Geoffrey. Is there a way to do this query?
Thanks in advance