I have a table named ChatThreadMember. I am attaching the data of the table so that my problem will be conveyed properly.
I am trying to fetch such a ChatThreadId which contains all the ReceiverInteral that I'll pass.
For ex. when I pass the following 3 ReceiverInternals
- 'F7269470-B8C9-447C-8E85-555D9ECF82B6'
- '79D49515-A34C-47A7-BDE8-667778B0327C'
- '9E682E2B-FB3C-41F3-9192-ABFD97D5A8F5'
I should get only 6CE1F6A9-8254-4D5A-8C9D-FEC680B60B2F as the ChatThreadId as it is the only ChatThreadId which contains all the 3 ReceiverInternals. However with my all trials I am getting DF04A5D4-E586-4398-B8DB-13B411EOED5D also along with 6CE1F6A9-8254-4D5A-8C9D-FEC680B60B2F which I don't need.
My query is:
SELECT cth.ChatThreadId from ChatThreadMember cth where cth.ReceiverInternal in
('F7269470-B8C9-447C-8E85-555D9ECF82B6','79D49515-A34C-47A7-BDE8-667778B0327C','9E682E2B-FB3C-41F3-9192-ABFD97D5A8F5')
and
cth.ChatThreadId not in(
SELECT cth.ChatThreadId from ChatThreadMember cth where cth.ReceiverInternal in
(Select cth.ReceiverInternal from ChatThreadMember cth where cth.ReceiverInternal not in ('F7269470-B8C9-447C-8E85-555D9ECF82B6','79D49515-A34C-47A7-BDE8-667778B0327C','9E682E2B-FB3C-41F3-9192-ABFD97D5A8F5')
))
group by cth.ChatThreadId
I am stuck with the problem. Any help? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire