I have a database table (Support_help_topic) which contains the following data:
topic_id | topic_pid | topic
What I want to be able to do is select a help topic, then get all its parent topics and concatenate them together.
Take the Following Example.
There are several parent help topics: Incidents, Requests, General Support
Each of these parent topics may have several child topics and the child topics may have additional topics under them.
The below is an example of a full help topic path
Incident / Software / Microsoft Outlook
Incident might have a
- topic_id of 1
- topic_pid of 0 (its a top level topic)
Software might have a
- topic_id of 20
- topic_pid of 1 (its parent is Incident)
Microsoft outlook might have a
- topic_id of 34
- topic_pid of 20 (its parent is Software)
I need to in each case get either of the following in a single select statement:
If the topic has parents i need to get: - Top_Level_Topic / Topic
If the topic has no parents i need to get:
- Topic
I am so stuck on this I have no idea where to begin.
Thanks in advance for any assistance. More than happy to provide an additional info needed.