SELECT word FROM words WHERE word LIKE '%searchstring%' ORDER BY CASE WHEN word LIKE 'searchstring%' THEN 1 WHEN word LIKE '%searchstring' THEN 3 ELSE 2 END