How to check %match between 2 string in prestosql?

1.5k Views Asked by At

What im looking for is I have 2 words e.g. 'Family' and 'Family Tree'

then I would love to know that how much does both texts match to each others.

let say 'Family' and 'Family' >> 100 %

not sure any workaround or not.

Thank you so much.

2

There are 2 best solutions below

3
Piyush Kachhadiya On

you can use like.

select * from tablename where fildname like '%Family%'

Result Give you all row in keyword is Family present.

0
Guru Stron On

For presto you can try looking into levenshtein_distance(string1, string2) → bigint built in function:

Returns the Levenshtein edit distance of string1 and string2, i.e. the minimum number of single-character edits (insertions, deletions or substitutions) needed to change string1 into string2.

Or (though it seems less suitable) hamming_distance(string1, string2) → bigint:

Returns the Hamming distance of string1 and string2, i.e. the number of positions at which the corresponding characters are different. Note that the two strings must have the same length.