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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:58:14+00:00 2026-05-13T15:58:14+00:00

I have 3 tables: articles, tags and article_tag (the one which connects them). I’d

  • 0

I have 3 tables: articles, tags and article_tag (the one which connects them).

I’d like to find all articles that have some (or all) of the tags listed in the query and order them by the number of matched tags. Is it possible?

Example in english:

Query: Find me all articles that have at least one of these tags "jazz, bass guitar, soul, funk", order them by the number of matched tags.

Output:
Article 1 (jazz, bass-guitar, soul, funk)
Article 2 (jazz, bass-guitar, soul)
Article 3 (jazz, bass-guitar)
Article 4 (funk)
  • 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-13T15:58:14+00:00Added an answer on May 13, 2026 at 3:58 pm

    Probably something like this:

    select articles.article_id, count(tags.tag_id) as num_tags, group_concat(distinct tag_name separator ',') as tags
    from articles, article_tag, tags
    where articles.tag_id = article_tag.tag_id
      and article_tag.tag_id = tags.tag_id
      and tags.tag_name in ( 'jazz', 'funk', 'soul', 'Britney Spears' )
    group by articles.article_id
    order by count(tags.tag_id) desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I've got two tables (articles and tags) that have a one-to-many relationship. I remember
I have three tables: articles(id int) tags(id int, name varchar(255)) articles_tags(article_id, tag_id) I want
I have a MySQL database with 3 tables: articles, tags, and articles_tags The schema
I have two quite large tables, let's call them 'authors' and 'articles'. Every row
I have a table articles that has a column company which has list of
I have three tables (users, articles, and tags) defined in SQLAlchemy and mapped with
Alright, I have done some research and found out that a good normalized articles
I currently have a database with two tables called Articles and Tags . In
I have a user model that can follow some tags User has_many :tag_followings has_many

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.