mysql - SQL Lite retrieve Proper Record -
i have table named chatthreadmember. attaching data of table problem conveyed properly.
i trying fetch such chatthreadid contains receiverinteral i'll pass.
for ex. when pass following 3 receiverinternals
- 'f7269470-b8c9-447c-8e85-555d9ecf82b6'
- '79d49515-a34c-47a7-bde8-667778b0327c'
- '9e682e2b-fb3c-41f3-9192-abfd97d5a8f5'
i should 6ce1f6a9-8254-4d5a-8c9d-fec680b60b2f
chatthreadid chatthreadid contains 3 receiverinternals. trials getting df04a5d4-e586-4398-b8db-13b411eoed5d
along 6ce1f6a9-8254-4d5a-8c9d-fec680b60b2f
don't need.
my query is:
select cth.chatthreadid chatthreadmember cth cth.receiverinternal in ('f7269470-b8c9-447c-8e85-555d9ecf82b6','79d49515-a34c-47a7-bde8-667778b0327c','9e682e2b-fb3c-41f3-9192-abfd97d5a8f5') , cth.chatthreadid not in( select cth.chatthreadid chatthreadmember cth cth.receiverinternal in (select cth.receiverinternal chatthreadmember cth cth.receiverinternal not in ('f7269470-b8c9-447c-8e85-555d9ecf82b6','79d49515-a34c-47a7-bde8-667778b0327c','9e682e2b-fb3c-41f3-9192-abfd97d5a8f5') )) group cth.chatthreadid
i stuck problem. help? in advance.
you want ids receiverinternal required exist. select them, count them in having clause , dismiss ids lower count.
select chatthreadid chatthreadmember receiverinternal in ( 'f7269470-b8c9-447c-8e85-555d9ecf82b6', '79d49515-a34c-47a7-bde8-667778b0327c', '9e682e2b-fb3c-41f3-9192-abfd97d5a8f5' ) group chatthreadid having count(distinct receiverinternal) = 3;
Comments
Post a Comment