-- create a table
CREATE TABLE test (
  id INTEGER PRIMARY KEY,
  parent int NOT NULL
);
-- insert some values
INSERT INTO test(parent) VALUES (0),(1),(2),(3),(4);


SELECT t1.parent p1, t2.parent p2, t3.parent p3
FROM test t1
JOIN test t2 ON t2.id = t1.parent
JOIN test t3 ON t3.id = t2.parent
WHERE t1.id = 5;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: