Re: Select rows when all all ids of its children records matches - Mailing list pgsql-general

From Ron
Subject Re: Select rows when all all ids of its children records matches
Date
Msg-id fe916369-aa51-0e7b-3afa-eb89974dfcc4@gmail.com
Whole thread Raw
In response to Select rows when all all ids of its children records matches  (Arup Rakshit <ar@zeit.io>)
Responses Re: Select rows when all all ids of its children records matches  (Arup Rakshit <ar@zeit.io>)
List pgsql-general
Maybe this:
select p.id, p.name
from posts p,
     posts_tags pt,
     tags t
where t.id in (1, 2, 3)
  and t.id = pt.tag_id
  and pt.post_id = p.id;


On 09/12/2018 10:23 AM, Arup Rakshit wrote:
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




--
Angular momentum makes the world go 'round.

pgsql-general by date:

Previous
From: Arup Rakshit
Date:
Subject: Select rows when all all ids of its children records matches
Next
From: Arup Rakshit
Date:
Subject: Re: Select rows when all all ids of its children records matches