Say I have a data base with classes and requirements that looks like this for example:
+--------+------+
| course |prereq|
+--------+------+
| 1 | null|
| 2 | null|
| 3 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
+--------+------+
And I want to find all the prereqs for course 4. So my answer would be 3,2,1.
Also this is just an example I want to be able to use this for a table of any size.
How would I go about doing this in mysql?