1

In Postgresql how to achieve separate search result with and without accent using like/ilike, something like this:

  • The record names are: cafe, café, cafeteria

  • If I use select name from cafe-table where name like '%cafe%'; then the result will be cafe, café, cafeteria

  • But If I select with %café% (with the accent) I just want the result is café

I've already tried unaccent but it makes the result the same for 2 queries.

Quang
  • 135
  • 2
  • 9

1 Answers1

2

You can use the unaccent module:

Install:

CREATE EXTENSION unaccent;

Then your query could look like this:

SELECT name 
FROM cafe-table 
WHERE unaccent(name) like '%cafe%'; -- use unaccent here
S-Man
  • 22,521
  • 7
  • 40
  • 63