Skip to content

Instantly share code, notes, and snippets.

@tylerpearson
Last active September 29, 2015 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerpearson/a8afde8f4e72db0f5e80 to your computer and use it in GitHub Desktop.
Save tylerpearson/a8afde8f4e72db0f5e80 to your computer and use it in GitHub Desktop.
sample SQL query to find related posts using a simhash
SELECT id, title, (LENGTH(CONV(fp ^ ?, 10, 2)) - LENGTH(REPLACE(CONV(fp ^ ?, 10, 2), '1', ''))) / LENGTH('1') AS comparison
FROM posts
ORDER BY comparison ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment