SQL Help help me write a Select Query

Job ID: 34366747

Budget: $10 – $30 AUD

See attached picture of the problem.

I need help writing a query that will be able to return this output.

The input is shown in green table, only has 2 columns.

I want a list of all the IDs and the original ID if that makes sense. Please see attached example.

The green table is a transactional table where one record is linked to the previous ID.

Please note, there could be hundreds unknown amount of links to previous records so need to think of an iterative or procedural way not just 3 nested select statements or something like that.

Please start your offer with the word purple so I know you have read this project description.

Thanks for your time and understanding.
Related categories: SQL Oracle MySQL