I have three tables.
tblLink: (LinkId, LinkName, GroupId, SubGroupId)
GroupId and SubGroupId are foreign keys in tblGroup and tblSubGroup
tblGroup: (GroupId, GroupName)
tblSubGroup: (SubGroupId, SubGroupName)
in tblLink SubGroupId is allowed Null, but GroupId is required.
I want to get LinkName, GroupName, SubGroupName for each LinkId in tblLink
I wrote a request
SELECT L.LinkName, G.GroupName, SG.SubGroupName FROM tblLink L
Left Join tblSubGroup SG
for sale (L.SubGroupId = SG.SubGroupId)
Internal registration
tblGroup G
for sale (L.GroupId = G.GroupId)
If there is no subgroup for any LinkId, I want to show NotExist instead of Null