I think this is what you were going for with your query:
SELECT
a.tr_numb AS granddaughter
,c.tr_numb AS grandfather
,a.tr_loc
,a.Tr_forest
FROM
Tree a, Tree b, Tree c
WHERE
a.tr_parent = b.tr_numb
AND b.tr_parent = c.tr_numb
AND a.tr_forest = c.tr_forest
AND a.tr_loc = c.tr_loc
Notice how a
, b
, and c
are aliases for the table Tree
. That's a self join. I'll leave that query here so you can try to see where you went wrong.
However, I wouldn't recommend that syntax for doing JOINs. It's much better to learn the more explicit syntax. Here's how I would write the query:
SELECT
Tree.Tr_numb AS tree
,Parent.Tr_numb AS parent
,Grandparent.Tr_numb AS grandparent
,Tree.tr_forest
,Tree.tr_loc
FROM
Tree
INNER JOIN Tree [Parent] ON (Parent.Tr_numb = Tree.Tr_parent)
INNER JOIN Tree [Grandparent] ON (Grandparent.Tr_numb = Parent.Tr_parent)
WHERE
Tree.Tr_loc = Grandparent.Tr_loc