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 4606710
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:36:11+00:00 2026-05-22T00:36:11+00:00

The original question is the following: Where A=1 AND A=2 returns 0 row problem

  • 0

The original question is the following:

Where A=1 AND A=2 returns 0 row problem – (Short Mysql question)

Thanks for some helpful answers. (but soon I realized I may have over-simplified the problem)

Actually the real problem is the following:

Tag 1,2,3 - category A
Tag 4,5,6 - category B
Tag 7,8,9 - category C

I want to achieve “OR condition” for the same category but “AND condition” for different category.
So I may want to return something like

-- I want id with Tag 1,4 or 1,2,4 but not 4
SELECT id FROM table WHERE Tag IN (1,2) AND Tag (4)

-- Tag 1,4 or 1,5 but not 1
SELECT id FROM table WHERE Tag IN (1) AND Tag (4,5)

-- Only Tag 1,4,9
SELECT id FROM table WHERE Tag IN (1) AND Tag (4) AND Tag (9)

I am trying to figure out from the answers, but any quick guide would be appreciated!

  • 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-22T00:36:12+00:00Added an answer on May 22, 2026 at 12:36 am

    From my understanding you want to return ids that are tagged over at least 2 different categroies, try this:

    Select id from Table 
    WHERE tag_category in (A,B,C) 
    Group by id 
    Having count(distinct tag_category) >= 2 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: original question below, but I revise it now that I have some code
Thanks for all your help - see blow original question, and my edit following
My original question can be found here , for which I've gotten some great
Jeff Atwood asked the original question about parameterizing a SQL IN clause , but
UPDATE 4: print_r( $data ); returns the data I posted in the original question,
In response to the helpful comments, I have edited the original question (where I
I recently asked a question about structs, and optimizing some overloaded operators. The original
This is a followup question from my original question: Best strategy for migrating mysql
Original question: Note: Below plugin pattern based on the official jQuery docs . I'm
Original Question: i read that for RESTful websites. it is not good to use

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.