SELECT t1.title, t1.version, t1.author, t1.time, t1.username, length, t1.comment, t1.mutable, t1.keywords, t1.body FROM pages t1 INNER JOIN (SELECT title, max(version) as version FROM pages GROUP BY title) t2 ON t1.title=t2.title AND t1.version=t2.version WHERE t1.title COLLATE LATIN1_GENERAL_CI LIKE '%herhn%' OR t1.body COLLATE LATIN1_GENERAL_CI LIKE '%herhn%'