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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:55:24+00:00 2026-05-14T01:55:24+00:00

This is a complicated situation (for me) that I’m hopeful someone on here can

  • 0

This is a complicated situation (for me) that I’m hopeful someone on here can help me with. I’ve done plenty of searching for a solution and have not been able to locate one. This is essentially my situation… (I’ve trimmed it down because if someone can help me to create this query I can take it from there.)

TABLE articles (article_id, article_title)

TABLE articles_tags (row_id, article_id, tag_id)

TABLE article_categories (row_id, article_id, category_id)

All of the tables have article_id in common. I know what all of the tag_id and category_id rows are. What I want to do is return a list of all the articles that article_tags and article_categories MAY have in common, ordered by the number of common entries.

For example:

article1 – tags: tag1, tag2, tag3 – categories: cat1, cat2

article2 – tags: tag2 – categories: cat1, cat2

article3 – tags: tag1, tag3 – categories: cat1

So if my article had “tag1” and “cat1 and cat2” it should return the articles in this order:

article1 (tag1, cat1 and cat2 in common)

article3 (tag1, cat1 in common)

article2 (cat1 in common)

Any help would genuinely be appreciated! Thank you!

  • 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-14T01:55:25+00:00Added an answer on May 14, 2026 at 1:55 am

    Okay, here’s my first draft:

     SELECT article_id, count(*) as common_term_count FROM 
          (
          SELECT article_id FROM tags WHERE tag IN 
             (SELECT tag FROM tags WHERE article_id = :YourArticle)
          UNION ALL 
          SELECT article_id FROM categories WHERE category IN
             (SELECT category FROM categories WHERE article_id = :YourArticle)
           ) AS accumulator_table 
     GROUP BY article_id ORDER common_term_count DESC
    

    I think this is valid MySQL syntax.

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

Sidebar

Related Questions

I have quite a complicated situation here. I can't find a better way to
I have a rather complicated Binding situation. I have a solution that I created
This is a complicated situation, but essentially what has happened here is that our
I have this complicated slider that utilizes tons of animation. I'm trying to find
I can't believe how unbelievably complicated this has been... I have the following XML...
Well the situation is bit more complicated than that ! I have a question
This is kind of a complicated situation. I'm refactoring (ground-up) c++ that must be
I'm a .Net developer but I have a situation where I can't guarantee that
I have this example here to illustrate the situation: http://jsfiddle.net/nubrF/40/ If you hold your
I have one complicated situation with JavaScript. I have created object. This object loads

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.