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%\
Try this:
SELECT s.pID FROM students s JOIN mentors m ON s.pID = m.pID WHERE m.tags LIKE '%a%' GROUP BY s.pID ORDER BY s.sID DESC;
I.e. GROUP BY instead of DISTINCT should preserve order.