sql - PostgreSQL match string to dynamically entered string -


i have varchar field in database table let's call store_name, field gets value entity a, entity b enters store_name different database table b want records in table store_name matches values in table b.

how recommend me doing query don't control values of 2 fields?

what think postgresql fuzzystrmatch? tables contain thousands of records.

thanks

assuming both table , table b in same database. , guess since don't control insertion of data, not sure if values of same case or there may spelling mismatch.

case 1: if problem of case-mismatch, can use ilike:

select a.store_name a, b a.store_name ilike b.store_name 

case 2: if want check spelling mismatch, words sound similar, after installing postgresql-contrib package , creating extension fuzzystrmatch, can use:

select a.store_name a, b a.store_name ilike b.store_name or soundex(a.store_name) = soundex(b.store_name) 

if dealing names, may not in english, may more appropriate use metaphone or dmetaphone function instead of soundex.

documentation: fuzzystrmatch


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -