Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. SET @str = 'Felix';
  2. SELECT * FROM (
  3. SELECT body, 1 AS table_order FROM articles AS a1 WHERE SOUNDEX(a1.body) = SOUNDEX(@str)
  4. UNION ALL
  5. SELECT body, 2 AS table_order FROM articles AS a2 WHERE levenshtein(body, @str) BETWEEN 0 AND 5 ORDER BY levenshtein(body, @str)
  6. ) AS articles ORDER BY table_order ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement