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

  • Home
  • SEARCH
  • 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 3215504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:11:08+00:00 2026-05-17T15:11:08+00:00

Does someone have a good idea/solution how to achieve this? Situation is: I have

  • 0

Does someone have a good idea/solution how to achieve this?

Situation is:
I have the tables ‘releases’ and ‘ntags’,
related via ‘releases_ntags’ (containing ‘release_id’ and ‘ntag_id’)

And I would like to fetch results for releases via the ntag’s ‘slug’.

I manage to have this semi-working:

sql

SELECT r.id, r.name
FROM releases r
LEFT JOIN ntags_releases rt ON rt.release_id = r.id
JOIN ntags nt ON nt.id = rt.ntag_id
AND (nt.name = ('TAG_1') OR nt.name = ('TAG_2'))
GROUP BY r.id, r.name

So far so good, but this gives me all releases with "TAG_1" PLUS all releases with "TAG_2" (and off course those with both tags).

But what I need is to only get the intersection of the tags, say:

"releases with ‘TAG_1’ AND ‘TAG_2’"

So i tried with:

...
AND (nt.name = ('TAG_1') AND nt.name = ('TAG_2'))
... 

But this leads in an empty result.
Does anyone have an idea how to achieve this? Don’t know how to go further on this and would really appreciate some input!

thx

  • 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-05-17T15:11:08+00:00Added an answer on May 17, 2026 at 3:11 pm

    You can demand that two distinct ntags are present in the having clause:

    SELECT  r.id, r.name
    FROM    releases r
    JOIN    ntags_releases rt
    ON      rt.release_id = r.id
    JOIN    ntags nt
    ON      nt.id = rt.ntag_id
    WHERE   nt.name in ('TAG_1', 'TAG_2')
    GROUP BY
            r.id, r.name
    HAVING
            COUNT(distinct nt.name) = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does someone have an idea how to get the environment variables on Google-AppEngine ?
Does someone know or have an idea of how to reload the contents of
Someone has an answer to this missing feature in Entity Framework. Does anyone have
Does someone have a good, fast SQL Server function that will take a string
Does someone have the source for Android loadable kernel module for libnfc? If not,
Assume you have a function read_key and normally it does some stuff. You someone
Does someone know a simple way to set the default zoom and latitude/longitude with
Does someone knows why the mysql_real_escape_string() function adds three backslashes before quotes, or double
Does someone know how to find the longest common subsequence of a set of
Does someone know why i never get the first value of my array? it

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.