Novice
Novice

Reputation: 443

sql query to match people based on interests

I have 3 tables.

I want to assign mentees to mentors. How do I match them ?

Also I was thinking of have one table for both the mentees and mentors.

Users Table(id,interest,location,role)

In this case will the querying be difficult ?

Thanks.

Upvotes: 0

Views: 424

Answers (1)

Barmar
Barmar

Reputation: 781721

Just join the two tables to find mentors and mentees that are in the same location and have the same interests.

SELECT t1.id AS Mentor_ID, t2.id AS Mentee_ID
FROM Mentors AS t1
JOIN Mentees AS t2 ON t1.interest = t2.interest AND t1.location = t2.location

Upvotes: 2

Related Questions