I have 2 tables Thread and Posts, i would like to search my posts and order by thread with most matches.
Right now i have this:
SELECT Threads.*
FROM Posts
INNER JOIN Threads ON Posts.ThreadID=Threads.ThreadID
WHERE Posts.Content LIKE '%" . $search . "%'
OR Posts.User LIKE '%" . $search ."%'
You could add a join to calculate the number of posts per thread. Since you’re not selecting any columns from Posts, that’s the only join you’ll need.