我有兩個類似的SELECT語句試圖獲得重疊,其中一個特定用戶的數據集和另一個是相同的。我有以下的,但不斷收到錯誤:SQL加入類似SELECTS
Msg 8156, Level 16, State 1, Line 30 The column 'PermissionId' was specified multiple times for 'T1'.
Msg 8156, Level 16, State 1, Line 40 The column 'PermissionId' was specified multiple times for 'T2'.
SELECT TOP 100 T1.Name, T1.permissionId
FROM (SELECT top 100 n.Name, rp.permissionId, rp.*
FROM dbo.[User] AS u
JOIN dbo.UserRole AS ur ON ur.UserId = u.UserId
JOIN dbo.ClientRole as cr on cr.RoleId = ur.RoleId
JOIN dbo.Name as n2 on cr.NameId = n2.NameId
JOIN dbo.RolePermissions AS rp on rp.RoleId = ur.RoleId
JOIN dbo.SystemTaxonomy AS st on st.SystemTaxonomyId = rp.PermissionId
JOIN dbo.Name AS n on st.NameId = n.NameId
WHERE u.LoginName IN ('user1')) AS T1
JOIN (SELECT top 100 n1.Name, rp1.permissionId, rp1.*
FROM dbo.[User] AS u1
JOIN dbo.UserRole AS ur1 ON ur1.UserId = u1.UserId
JOIN dbo.ClientRole as cr1 on cr1.RoleId = ur1.RoleId
JOIN dbo.Name as n2 on cr1.NameId = n2.NameId
JOIN dbo.RolePermissions AS rp1 on rp1.RoleId = ur1.RoleId
JOIN dbo.SystemTaxonomy AS st1 on st1.SystemTaxonomyId = rp1.PermissionId
JOIN dbo.Name AS n1 on st1.NameId = n1.NameId
WHERE u1.LoginName IN ('user2')) AS T2
ON T1.rp.permissionId = T2.rp1.permissionId
是否有人可以指導我,什麼是錯的?
在此先感謝
看rp.permissionId,RP *和嘗試rp.permissionId AS Perm_ID,RP 。*或刪除rp.permissionId – etsa