So I have two tables students (PK sID) and mentors (PK pID). This query
SELECT s.pID
FROM students s JOIN mentors m ON s.pID = m.pID
WHERE m.tags LIKE \'%a%\
After struggling some more I have this
SELECT s.pID, MAX(s.sID) AS newest_student
FROM students s JOIN mentors m ON s.pID = m.pID
WHERE m.tags LIKE '%a%'
GROUP BY s.pID
ORDER BY newest_student DESC;
which gives me the required 9,3,10 but I have one useless field returned with it. I am hoping some-one will come with a better solution.