Not strong in recursive queries, so I would be grateful if you would help with such a task: there is a table Chair (Chair) and its structure: ID | Name | IsActive | HistLink
ID | Name | IsActive | HistLink
ID | Name | IsActive | HistLink
. When the name of the department changes, the following occurs at the old department: The IsActive field c 1 changes to 0, and then the department is added (added) with a new name and an ID of the old department in the HistLink field. For example:
ID | Name | IsActive | HistLink 3 | Старое_название | 0(была 1) | null 5 | Новое_название | 1 | 3
And somehow you need to define the current (active) ID by the 1st request, knowing the ID of the old department (And of course the name can change> 1 time). Thanks in advance.