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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:00:31+00:00 2026-05-25T12:00:31+00:00

I have a MySQL database with 3 tables: The main table of records called

  • 0

I have a MySQL database with 3 tables:

  1. The main table of records called
    “tracks” (as in music)
  2. A tags table
    called “tags”
  3. A join table for the two called “taggings”

The tags table is basically a list of genres, which is pre-defined. A track can then have 1 or more tags (via the join table).

The idea is, that the user checks off the genres (tags) for which he or she want to find tracks. But I would also like the interface to reflect which tags are no longer “useful”, that is, tags which are complementary to the currently selected ones.

Edit: What I missed was that I need to find tags that are complementary to the currently selected set of tags. See my comment below.

Example: the user selects the “rock” and “pop” tags, and is shown a list of tracks that match “rock” + “pop”. But suppose there are no tracks in the database that also match “jazz”. In that case, I’d like to disable the “jazz” tag in the interface, because “rock” + “pop” + “jazz” would give zero results.

Is there a clever way to do this with MySQL?

  • 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-25T12:00:31+00:00Added an answer on May 25, 2026 at 12:00 pm

    Ended up doing this:

    • When a track is tagged, its tag IDs are concatenated (in order) and added to a 1-column lookup table (and of course also to taggings). E.g. “,1,2,4,6,9,” is added to the lookup (there’s a reason for the leading/trailing commas)
    • When tags are selected while searching, they’re similarly concatenated, and used in a LIKE clause which selects all the concatenations from the lookup table that contain those tag IDs
    • The found concatenations are then processed to get all the IDs that they contain
    • Whichever IDs are not in the resulting list are thus complementary to the selected ones
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a small DataBase with MySQL Workbench. I have a main table, called
I have a MySQL database with 3 tables: articles, tags, and articles_tags The schema
I have two tables in my MySQL database, one is a library of all
I have two tables in my SQL database: mysql> select *from crop; +------+-----------+----------+ |
I have a MySQL database with 3 tables: **articles:** id - articletitle - articleorganization
I have a MySQL database with multiple tables, each of which have the same
I have a MySQL database with 60 tables. Most of the tables have primary
Suppose I am building an app using current mysql database tables. I have this
I have a MySQL database with a few (five to be precise) huge tables.
I have a MySQL database set-up in a hierarchy style. There are 4 tables

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.