So I am trying to retrieve all interests from someone, and be able to list them. This works with the following query.
SELECT *,(
SELECT GROUP_CONCAT(interest_id SEPARATOR ",")
FROM people_interests
WHERE person_id = people.id
) AS interests
FROM people
WHERE id IN (
SELECT person_id
FROM people_interests
WHERE interest_id = '.$site->db->clean($_POST['showinterest_id']).'
)
ORDER BY lastname, firstname
In this one which I am having trouble with, I want to select only those who happen to have their id in the table named volleyballplayers. The table just has an id, person_id, team_id, and date fields.
SELECT *,(
SELECT GROUP_CONCAT(interest_id SEPARATOR ",")
FROM people_interests
WHERE person_id = people.id
) AS interests
FROM people
WHERE id IN (
SELECT person_id
FROM people_interests
WHERE volleyballplayers.person_id = person_id
)
ORDER BY lastname, firstname
I just want to make sure that only the people who are in the volleyballplayers table show up, but I am getting an error saying that Unknown column 'volleyballplayers.person_id' in 'where clause' although I am quite sure of the name of table and I know the column is named person_id.