Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:48:48+00:00 2026-06-12T20:48:48+00:00

I have three tables: posts, tags and posts_has_tags (which facilitate the many-to-many relationship between

  • 0

I have three tables: posts, tags and posts_has_tags (which facilitate the many-to-many relationship between posts and tags). A post can have any number of tags.

The ‘posts’ table has the following columns:
idposts
text

The ‘tags’ table has these:
idtags
name

As for the ‘posts_has_tags’ table:
posts_idposts
tags_idtags

What I can’t do is come up with a query to select all posts except for those which have a tag (or tags) with a certain value in the ‘name’ column assigned to them. It seems that it should contain a “NOT EXISTS”, but I can’t really fully wrap my head around it.

Thank you for your help in advance.

EDIT:

Also, is it possible to restrict the result set to certain tags at the same time? For example:

tags for exclusion: a, b
tags for inclusion: c

Post with tags ‘a’, ‘f’ doesn’t make it into result set (because none if it’s tags are included).
Post with tags ‘a’, ‘b’, ‘c’ doesn’t make it into result set either (because it’s ‘a’ and ‘b’ are excluded tags).
Post with tags ‘c’, ‘f’ does make it into result set, because ‘c’ is the included tag.

FINAL EDIT
I finally found a solution that seems to be working and reasonably well-performing: http://www.mysqldiary.com/a-many-to-many-relationship-table-solving-the-exclude-relation-problem/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:48:50+00:00Added an answer on June 12, 2026 at 8:48 pm

    I finally found a solution that seems to be working and reasonably well-performing: http://www.mysqldiary.com/a-many-to-many-relationship-table-solving-the-exclude-relation-problem/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: Post, Attachment, and Media. Posts have Attachments, and Attachments have
I have Three tables, Posts, Tags, Posts_Tags_Link Posts has: id, content Tags has: id,
Suppose I have the following three tables expressing a relationship where posts are given
In my application I have many-to-many relationship (mapped with FluentNHibernate) between Post and Tag:
I basically have three tables, posts, images and postimages (this simply contains the ids
I have three tables (individuals, groups & recordlabels) and want use the information between
I've got three tables posts tags posts_tags I need to write some controller logic
So, I'm going to say that I have three tables as follows: POSTS POSTS_TAGS
I simplified a many-to-many relationship case with these mockup tables. Posts: ------------------------------ | id
I have 2 tables: posts tags Tags table is structured like this: post_id tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.