diff --git a/README.md b/README.md index 5ceeda6..03befad 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_833 TILs and counting..._ +_834 TILs and counting..._ --- @@ -389,6 +389,7 @@ _833 TILs and counting..._ - [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md) - [Clear The Screen In psql (2)](postgres/clear-the-screen-in-psql-2.md) - [Compute Hashes With pgcrypto](postgres/compute-hashes-with-pgcrypto.md) +- [Compute The Levenshtein Distance Of Two Strings](postgres/compute-the-levenshtein-distance-of-two-strings.md) - [Compute The md5 Hash Of A String](postgres/compute-the-md5-hash-of-a-string.md) - [Configure The Timezone](postgres/configure-the-timezone.md) - [Constructing A Range Of Dates](postgres/constructing-a-range-of-dates.md) diff --git a/postgres/compute-the-levenshtein-distance-of-two-strings.md b/postgres/compute-the-levenshtein-distance-of-two-strings.md new file mode 100644 index 0000000..4c62f27 --- /dev/null +++ b/postgres/compute-the-levenshtein-distance-of-two-strings.md @@ -0,0 +1,21 @@ +# Compute The Levenshtein Distance Of Two Strings + +PostgreSQL has a built-in function for computing the [Levenshtein +distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between two +strings. + +```sql +> select levenshtein('hello', 'world'); + levenshtein +------------- + 4 + +> select levenshtein('function', 'funtcion'); + levenshtein +------------- + 2 +``` + +Check out the [`fuzzystrmatch` +module](https://www.postgresql.org/docs/current/fuzzystrmatch.html#id-1.11.7.24.6) +for more details.