Stumbled upon this problem recently, and am struggling to do it in SQL. The table in question is in the form of course, then required course.
Example: Course Requirement
MATH ENG ENG SCI ENG PHYSICS PHYSICS BIO
In a standard programming language, this can be done by some sort of search algorithm to get a list of dependencies (note that they can be nested as MATH DEPENDS ON ENG which depends on SCI), but I have no idea how one would do this with SQL. I tried using joins on equality, but the fact that they can be nested is throwing me off...
So if the query is MATH, then it should return ENG, SCI, PHYSICS, BIO