Lacwik
#sql #programowanie

Ok, mam tabelę:

Assignment
[UserId]
[GroupId]
[UpdatedBy]
[UpdatedAt]

mam również funkcję, pozwalającą mi na pobranie wszystkich użytkowników w danej grupie:

select UserId from dbo.GetGroupUsers() ggu where ggu.GroupId = ?

potrzebuję sprawdzić, do jakich grup należy dany użytkownik (znając jego id) a następnie pobrać WSZYSTKICH użytkowników z tych grup bez duplikatów.

Jak mogę to osiągnąć?
  • Najlepsze
  • Wszystkie komentarze
S.....s
S.....s
@Lacwik: select * from users where groupid = (select groupid from users where userid = xx)
S.....s
S.....s
@Lacwik: select userid from ggu where groupid in (select groupid from ggu where userid=xx)
S.....s
S.....s
@Lacwik: distinct
Lacwik
Lacwik Autor
0
@SuppressWarnings: subquery returned more than 1 value. This is not permitted when subquery is used as an expression
S.....s
S.....s
@Lacwik: no to coś z------ś, bo user z konkretnym id powinien być jeden
S.....s
S.....s
@Lacwik: a dobra chwila
Lacwik
Lacwik Autor
0
@SuppressWarnings: podziękował, prosta rzecz a dziura w mózgu i sie z tym męczyłem za długo. Przypomnisz mi jeszcze prosze jaka była dyrektywa na niepożądane duplikaty?