I have this people and tags table, like this,
CREATE TABLE people
AS
SELECT *
FROM ( VALUES
(1,'Joe'),
(2,'Jane')
) AS t(id,name);
CREATE TABLE tags
AS
SELECT * FROM ( VALUES
(1, 1, 'np'),
(2, 1, 'yw'),
(3, 2, 'np')
) AS t(id, people_id, tag);
If I want to find all people that contain both the np and yw tags in the tags table using a join, how would I do this efficiently in Postgres 9.6?
In this scenario, I should only get Joe's record from the people table.