Re: Select rows when all all ids of its children records matches

Поиск
Список
Период
Сортировка
От Arup Rakshit
Тема Re: Select rows when all all ids of its children records matches
Дата
Msg-id 5E56CBFF-62E6-4C17-B6D8-BBC05BC10C8B@zeit.io
обсуждение исходный текст
Ответ на Re: Select rows when all all ids of its children records matches  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: Select rows when all all ids of its children records matches
Список pgsql-general
IN is OR, I want the AND logic. Select posts which has tag 1, 2 and 3 ( tag ids )


Thanks,

Arup Rakshit



On 12-Sep-2018, at 8:58 PM, Ron <ronljohnsonjr@gmail.com> wrote:

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 по дате отправления:

Предыдущее
От: Ron
Дата:
Сообщение: Re: Select rows when all all ids of its children records matches
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Select rows when all all ids of its children records matches