'PostgreSQL like-search by Korean doesn't work
Here is the specification of my PostgreSQL.
- PostgreSQL 12.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit
- server_encoding : UTF8
- client_encoding : UTF8
With table 'a', like-search by Korean works perfectly.
SELECT * FROM a
WHERE name LIKE '%가%' escape '!'
-- result
seq name
001 가족
002 나가
003 가
But with table 'b', like-search by Korean doesn't work at all and only equal-search shows results.
SELECT * FROM b
WHERE name LIKE '%가%' escape '!'
-- result
no rows
At the first look, I suspected the encoding of the database but as I mentioned in the first line the encodings of the server and client are the same 'UTF8'. Furthemore, in the same condition the table 'a' shows perfect results. I don't know where to start to figure this out.. If you guys give me any suggestion it would be super appreciated.
Solution 1:[1]
guys finally I found the root problem. The column 'name' in the where clause was supposed to save a name of an uploaded file. The file was generated in MAC and this is the problem. If the name of the file is '??' which means Korean in Korean, it should be displayed and stored like '??' but in MAC it shows '??' on the screen but stored in the DB like '??????' actually.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Inye Yu |