JOIN table to itself - complex query - writers block
Hello, all.
I've got a table in a SQL 2000 server that is used for navigation. It contains three tiers of navigation; primary, secondary, tertiary. I'll post a basic example of it.
Code:
=========================================================
| ID | nav_name | nav_parent | URL | active |
=========================================================
| 0| Home | 0 | index.cfm | Y |
-------------------------------------------------------------------------
| 1| Get Started | 0 | NULL | Y |
-------------------------------------------------------------------------
| 2| Install | 1 | start.cfm?m=install | Y |
-------------------------------------------------------------------------
| 3| Setup | 1 | start.cfm?m=setup | Y |
-------------------------------------------------------------------------
| 4| Register | 3 | register.cfm | Y |
-------------------------------------------------------------------------
| 5| Pick a Project | 0 | NULL | Y |
-------------------------------------------------------------------------
| 6| Find Available | 5 | NULL | Y |
-------------------------------------------------------------------------
| 7| Category | 6 | start.cfm?m=project&s=cat | Y |
--------------------------------------------------------------------------
| 8| Type | 6 | start.cfm?m=project&s=typ | Y |
--------------------------------------------------------------------------
I'm trying to create a query that will get nav_name, regardless of whether or not URL is null, based upon the filename that is passed (index, start, register), so it needs to look at parent navs.
I started doing this, but keep getting blocked. It works if the 2nd tier nav has a URL, but if it doesn't, then I can't seem to make it look for either 1st tier (if not null) or 3rd tier (if 1st tier AND 2nd tier are NULL).
Bookmarks