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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:22:28+00:00 2026-06-02T20:22:28+00:00

I am creating a music website where I would like users to be able

  • 0

I am creating a music website where I would like users to be able to find users who like approximately the same artists as they.

I have a ‘like’ table that has 2 columns ‘id_user’, ‘id_artist’.
Here is an example of how I would like it to work:

User 1 likes:
1, 12
1, 13
1, 14
1, 26
1, 42
1, 44

User 2 likes:
2, 13
2, 14
2, 15
2, 26
2, 42
2, 56

Those 2 users have 4 artists in common.
Is there a way, to compare those 2 results sets, to find the most similar people in the database?

My first idea was to concatenate likes in that way: “12,13,14,26,42,44” in a string, and use mysql FULLTEXT scores to compare different strings.
That didn’t work… don’t know why but mysql fulltext only works with text… not with numbers…

Any idea or any clue would be much 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-06-02T20:22:30+00:00Added an answer on June 2, 2026 at 8:22 pm

    Something like this:

    SELECT first_user.id_user, second_user.id_user, COUNT(first_user.id_user) AS total_matches
    
    FROM likes AS first_user
    
    JOIN likes AS second_user
    ON second_user.id_artist = first_user.id_artist
    AND second_user.id_user != first_user.id_user
    
    GROUP BY first_user.id_user, second_user.id_user
    
    ORDER BY total_matches DESC
    
    LIMIT 1
    

    Note that this isn’t very efficient. One way to work around this is to make a ‘cache table’ containing the output of this query with the LIMIT 1 portion removed. Add some relevant indexes and do query this cache table. You could set a cron job to update this table periodically.

    Example:

    CREATE TABLE IF NOT EXISTS `likes` (
      `id_user` varchar(50) DEFAULT NULL,
      `id_artist` varchar(50) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    INSERT INTO `likes` (`id_user`, `id_artist`) VALUES ('8', '39'), ('8', '37'), ('4', '37'), ('8', '24'), ('8', '7'), ('4', '28'), ('8', '28'), ('4', '27'), ('4', '11'), ('8', '49'), ('4', '7'), ('4', '40'), ('4', '29'), ('8', '22'), ('4', '29'), ('8', '11'), ('8', '28'), ('4', '7'), ('4', '31'), ('8', '42'), ('8', '25'), ('4', '25'), ('4', '17'), ('4', '32'), ('4', '46'), ('4', '19'), ('8', '34'), ('3', '32'), ('4', '21')
    
    +---------+---------+---------------+
    | id_user | id_user | total_matches |
    +---------+---------+---------------+
    | 8       | 4       |             7 |
    +---------+---------+---------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating the website of a music band. The band would like to have
I am creating a music streaming website like Grooveshark. I have done the coding
I am creating an Android application which will have some embedded music inside of
I am making a simple music playing online app. I would like to make
I am creating a music web app that streams MP3s that I have stored
I'm creating a old school music emulator for the old GWBasic PLAY command. To
Creating a server-side socket will fail if I'm trying to use the same port
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
When creating iPhone apps in simulator, I sometimes see messages like Springboard failed to
i am creating a music application and i want to integrate facebook into my

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.