I have a simple relational database set up similar to the example below
[Customer] --< [CGLink] >-- [Order]
Person:
Alias Name(PK)
A Bill
B Ben
C Bob
D Jim
E John
CGLink:
ID(PK) Alias Type
1 A W
2 A X
3 B W
4 B X
5 B Y
6 B Z
7 C Y
8 E Z
Group:
Type(PK) Group
W Double-U
X Eks
Y Whai
Z Zed
And I want to return a set of results like
Alias Name Group
A Bill Double-U
A Bill Eks
B Ben Double-U
B Ben Eks
B Ben Whai
B Ben Zed
C Bob Whai
D Jim
E John Zed
As you can see Jim had no associated data in the linking table and I want to avoid having to place a row of dummy data that I can link all people to who don't have a group in order to let me return this data.
The query I am using is
SELECT p.Alias, p.Name, g.Group
FROM Person AS p, Group AS s, CGLink AS l
WHERE (p.Alias=l.Alias
AND l.Type=s.Type)
ORDER BY p.Alias, p.Name;
This returns
Alias Name Group
A Bill Double-U
A Bill Eks
B Ben Double-U
B Ben Eks
B Ben Whai
B Ben Zed
C Bob Whai
E John Zed
Which as you can see, is missing Jim because he had no associated group. How can I obtain the results I really want?
Cheers