You are getting one result only because you are calculating the average .. In order to get multiple results while using a function like AVG()
or COUNT()
etc .. You need to use GROUP BY
You might try something like this:
SELECT s.*,
ROUND(AVG(r.rank),0)
AS avrank
FROM stories s
LEFT JOIN ratings
AS r ON r.storyidr = s.id
GROUP BY title
HAVING title
LIKE '%$find%'
LIMIT 50;