I have 3 tables
- Links
Link ID
Link Name
GroupID (FK into Groups)
SubGroupID (FK into Subgroups) -
Groups
GroupID
GroupName -
SubGroup
SubGroupID
SubGroupName
GroupID (FK into Groups)
Every link needs to have a GroupID but teh SubGroupID is optional. How do i write a SQL query to show:
Links.LinkName, Groups.GroupName, SubGroup.SubGroupName
For the records with no subgroup just put a blank entry in that field. If i have 250 link rows, i should get back 250 reecords from this query.
Is there a way to do this in one query or do i need to do multiple queries?
This assumes that there is at most only 1 subgroup per group. if there are more, then you have the potential to get additional records.