Select rows when all all ids of its children records matches

From: Arup Rakshit <ar(at)zeit(dot)io>
To: pgsql-general(at)postgresql(dot)org
Subject: Select rows when all all ids of its children records matches
Date: 2018-09-12 15:23:34
Message-ID: FF55BC81-BB56-45C3-BCA2-B7D0F8E81F4A@zeit.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table posts(id, name), posts_tags(post_id, tag_id) and tags (id, name) ... I want to get all posts which has tag id 1, 2 and 3 for example. How should I do this? I tried ALL, but it didn’t work.

Those tag ids comes from UI by users, so I am looking for generic approach.

Thanks,

Arup Rakshit
ar(at)zeit(dot)io

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2018-09-12 15:28:27 Re: Select rows when all all ids of its children records matches
Previous Message Ron 2018-09-12 14:40:19 Re: PG9.1 migration to PG9.6, dump/restore issues