AndreDurao
AndreDurao

Reputation: 5795

Postgresql query to lookup emojis

I'm trying to lookup emojis on a table on postgresql.

Sometimes I've got this on my results:

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

85981  | [<U+1F6AB>] forbidden sample text

I've tried to lookup which titles have this emoji using the following queries:

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%'

But none of these gave me the results that I want.

How to properly write this unicode character?

Upvotes: 5

Views: 1905

Answers (1)

jimbonk
jimbonk

Reputation: 111

Using the Postgres escape sequence might be what you're looking for: WHERE title LIKE E'%\u1F6AB%'.

Upvotes: 1

Related Questions