用于查找表情符号的 Postgresql 查询

And*_*rao 5 sql postgresql unicode emoji

我正在尝试在 postgresql 的表上查找表情符号。

有时我的结果是这样的:

# SELECT id, title FROM my_texts WHERE title ILIKE '[%';
  id   |                             title
-------+---------------------------------------------------------------

85981  | [<U+1F6AB>] forbidden sample text
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下查询查找哪些标题具有此表情符号:

SELECT id, title FROM my_texts WHERE title ILIKE '%<U+1F6AB>';
SELECT id, title FROM my_texts WHERE title ILIKE '%\U+1F6AB%'
SELECT id, title FROM my_texts WHERE title ILIKE '%\U1F6AB%'
Run Code Online (Sandbox Code Playgroud)

但是这些都没有给我想要的结果。

如何正确编写这个 unicode 字符?

小智 1

您可能正在寻找使用 Postgres 转义序列:WHERE title LIKE E'%\u1F6AB%'