There is a table to link posts and tags

And I need to get valid post_id which has tag_id 2 and 8.
I can find record with tag_id 2, save the post_id and look at this more post_id and tag_id 8, but tags can be 5 and it will be 100500 queries.
Or maybe you have other ideas for implementations communication of tags with the posts and search for them?