2
我在表「OG」中有一列「名稱」和「ids」,並且希望找到最後一個字母不同且總編輯距離爲兩個的那些名稱。到目前爲止,我有:設置一個字符串的最後一個字母等於PostgreSQL
SELECT
z1.names as names1, z2.names as names2, z1.ids, z2.ids
FROM (SELECT t.names, SUBSTRING(t.names for Length(t.names-1) AS newnames
from "OG" t) z1, (SELECT r.names, SUBSTRING(r.names for Length(r.names-1) AS
newnames1 FROM "OG" r) z2
WHERE levenshtein(z1.newnames, z2.newnames1) = 2 AND z1.id != z2.id
不幸的是,這並不能確保最後的字母是不同的。任何想法修復?
超爽!謝謝! – 2011-04-03 21:55:41