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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:38:05+00:00 2026-05-18T05:38:05+00:00

Sorry for the abysmal title – if someone wants to change it for something

  • 0

Sorry for the abysmal title – if someone wants to change it for something more self-explanatory, great – I’m not sure how to express the problem. Which is:

I have a table like so:

POST_ID (INT)   TAG_NAME (VARCHAR)

    1              'tag1'
    1              'tag2'
    1              'tag3'
    2              'tag2'
    2              'tag4'
   ....

What I want to do is count the number of POSTs which have both tag1 AND tag2.
I’ve messed about with GROUP BY and DISTINCT and COUNT but I can’t construct a query which does the trick.
Any suggestions?

Edit: In pseudo sql, the query I want is:

SELECT DISTINCT(POST_ID) WHICH HAS TAG_NAME = 'tag1' AND TAG_NAME = 'tag2'; 

Thanks

  • 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-18T05:38:06+00:00Added an answer on May 18, 2026 at 5:38 am

    Edit: because ‘TABLE’ was a poor choice for a missing tablename, I’ll suppose your table is called Posts.

    Join the table against itself:

    SELECT * FROM Posts P1
    JOIN Posts P2
    ON P1.POST_ID = P2.POST_ID
    WHERE P1.TAG_NAME = 'tag1'
    AND P2.TAG_NAME = 'tag2'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sorry if the title is worded oddly, not really sure how to say it.
Sorry for the long and self explanatory title, but UIScrollView has raised so many
(Sorry for the not-so-good-title, I'm not sure how my problem can be solved, thus
Sorry for the bad title - I simply do not know what to call
Sorry but I am not sure how to ask this question but I am
Sorry the title is not very descriptive but it is a tricky problem to
Sorry if the title is not clear enough, I have <a> elements with the
Sorry, I'm not even sure how to ask this question.. so if you could
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry for the odd wording, I'm not sure how to describe what I need

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.