I'm trying to figure out how to perform what would essentially be a recursive query in SQL. I've got two tables;
TABLE Object(
id INT NOT NULL PRIMARY KEY
)
TABLE ObjectDependency(
object_id INT,
dependency_id INT,
FOREIGN KEY(object_id) REFERENCES Object(id)
FOREIGN KEY(dependency_id) REFERENCES Object(id)
)
I want to write a stored procedure that will take an object id and spit out all of the objects dependancies (something like this, but also any found dependency's dependency.
SELECT id, ObjectDependency.id FROM Object
JOIN ObjectDependency ON object_id = id
The system is set up in such a way that there are no cyclical dependancies, but I'm kind of lost on how I would manage to loop all results into one stored procedure.