韩语的postgresql类似搜索

发布于 2025-01-28 18:32:28 字数 692 浏览 1 评论 0原文

这是我的PostgreSQL的规范。

  • X86_64-PC-Linux-gnu上的PostgreSQL 12.8,由GCC(GCC)4.8.5 20150623(Red Hat 4.8.5-11),64- bit
  • Server_encoding:utf8
  • client_encoding:utf8 client_encoding:utf8,

带有表'a',a',a'韩国人工作得很好。

SELECT * FROM a
WHERE name LIKE '%가%' escape '!'

-- result
seq  name
001  가족
002  나가
003  가

但是,对于表“ B”,韩语的类似搜索根本不起作用,只有同等搜索显示结果。

SELECT * FROM b
WHERE name LIKE '%가%' escape '!'

-- result
no rows

首先,我怀疑数据库的编码,但是正如我在第一行中提到的服务器和客户端的编码相同的“ UTF8”。 此外,在相同情况下,表“ A”显示了完美的结果。 我不知道从哪里开始弄清楚这一点。 如果你们给我任何建议,将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云归处 2025-02-04 18:32:28

伙计们终于发现了根问题。
该列在Where子句中的列“名称”应该保存上传文件的名称。该文件是在Mac中生成的,这是问题所在。
如果文件的名称为'한글',在韩语中表示韩语,则应像'한글'一样显示和存储,但在Mac中显示在屏幕上,但实际上存储在db中,如'ㅎㅏㄴㄱㅡㄹ' 。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文