I have inherited a system which seemingly requires me to use a cursor or while loop.
Given the below tables, I would like to get the names of the attendees e.g
Bill
Bob
Jane
JillAttendees
SourceTable|SourceTableId
Boys |1
Boys |2
Girls |2
Girls |1Boys
Id|FirstName
1 |Bill
2 |BobGirls
Id|FirstName
1 |Jill
2 |Jane
Note, the system doesn’t actually use Attendees,Boys & Girls but rather uses Contracts, Orders and other such entities etc but it was easier\simpler to represent in this form.
There may be loads more lookup tables than just “boy” and “girl” so
Is there anyway I can achieve this by not using cursors or other row based operations.
If I understand this query should work: