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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:41:13+00:00 2026-06-13T06:41:13+00:00

I need to create a query that suggests artists to users depending on what

  • 0

I need to create a query that suggests artists to users depending on what they like and what other people who like what they like like. Hope you get that.

Anyhow, the tables in question are members (self explanatory) and artist_follows (which members follow who). I will add this query into a bigger query later on that will also get the artist info from the artists table for that ID.

Here’s what I have so far, i’ve used 2 as the mock ID for the member.

SELECT 

M.ID AS M_ID,

F.ID AS F_ID,
F.follows_ID

FROM members M

LEFT JOIN artist_follows F 
ON F.ID = M.ID

WHERE M.ID ='2'

I realise its not very much at all but its as far as I can get hence why I came here.

Heres a breakdown of what needs to be done:

1: Get ID from members table.

2: Get follows_ID (who the user follows) from artist_follows by using the members ID

3: Get IDS of people who follow who the member follows. (call this “other members IDS” for the purpose of the next point).

4: Get other artists IDS from “other members IDS” making sure artists that are already followed by the member aren’t selected.

Hope breaking it down like that has helped!

UPDATE!
Lets have some mock data as suggested then. Lets say the member 2 follows artists with IDS 3 . Another member (4) follows 3 as well as 20. The outcome of the query should therefore be 20

Schema:

artist_follows;

CREATE TABLE `artist_follows` (
 `ID` int(11) NOT NULL,
 `follows_ID` int(11) NOT NULL,
  KEY `fav_ID` (`ID`),
  CONSTRAINT `fav_ID` FOREIGN KEY (`ID`) REFERENCES `artists` (`ID`),
  CONSTRAINT `ID` FOREIGN KEY (`ID`) REFERENCES `members` (`ID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

members;

CREATE TABLE `members` (
 `ID` int(111) NOT NULL AUTO_INCREMENT,
 `email` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `password` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `FNAME` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `SURNAME` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (`ID`),
 UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
  • 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-13T06:41:14+00:00Added an answer on June 13, 2026 at 6:41 am
    SELECT DISTINCT new.follows_ID
    FROM artist_follows fan
    INNER JOIN artist_follows other ON other.follows_ID = fan.follows_ID
    INNER JOIN artist_follows new ON new.ID = other.ID
    WHERE new.follows_ID NOT IN
        (SELECT follows_ID FROM artist_follows WHERE ID = fan.ID )
    AND fan.ID = 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a MySQL query that generates 4 rows for each row
I have a database that I've inherited and need to create a query that
I'm having problems trying to get a query like this table answers CREATE TABLE
I need to create a query in NHibernate that would search for a product
I need to create a xpath query that will return everything listed under availabilty
i need to change my query from native-query to ( named-query or create-query )
I'm used to create query with createQuery() instead of queryBuilder, but I need to
I have a query being created using OLEDB from access and need to get
I need create clone repository. but I do not know where can I get
I'm trying to create a query that will group results BY where the grouped

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.