我有三个表格,用于指定
下面的重要列Association.UserID = Users.Id,Association.GroupId = Groups.id以及Groups.creator = Users.Id。
我需要的是显示所有数据的至少三列
答案 0 :(得分:2)
SELECT G.GroupName, U1.UserName AS GroupCreator U2.UserName AS GroupMember
FROM Groups AS G
INNER JOIN Users AS U1
ON G.Creator = U1.ID
LEFT JOIN Association AS A
ON A.GroupID = G.ID
LEFT JOIN Users AS U2
ON U2.ID = A.UserID