Skip to content
Advertisement

How to find ‘MAIN’ master record SQL

I’m running a query:

Which returns the following results: Companies

I just so happen to know these IDs and am using them for this example.

How can I return results like this across the board grouping together linked companies, until I get to the ‘MAIN’ company.

There are going to be several other companies where I don’t know the IDs I want to be able to basically group these results together so I can keep getting the MAIN company return with it’s parent child association.

Advertisement

Answer

I’ve just managed to get my CTE working

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement