Guys,
Its been a while since I last visited here, and the site's SO much faster now, great to see because it used to be a great cause of frustration as the forum pages crawled up!
Anyway...I need to write a SQL query that I just cannot get my head around, I'm sure there's a really simple solution but after hours of scratching my head, a simple way of forming it hasn't occurred to me.
So, I've built the following DB structure (simplified example of it):
1: tbl_users
UserID
UserName
2: tbl_interests
InterestID
InterestName
3: tbl_linkuserstointerests
LinkID
LinkUserID
LinkInterestID
I have a form within my website where users can search for users that match one or more interests, so after submitting the form I end up with a checkbox[] array that implodes to "5,3,4,8,2" - how do I take this to find all users that match at least one of the interests?
My gut feeling wants to do something like this...but I know this isn't going to work but will hopefully illustrate something similar to what I am trying to achieve.
SELECT UserID, UserName FROM tbl_users WHERE UserID IN (SELECT LinkUserID FROM tbl_linkuserstointerests WHERE LinkInterestID IN 5,3,4,8,2)
Can anyone help? 😃
p.s. its good to be back!