Re: SELECT in VCHAR column for strings with TAB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthias Apitz <guru(at)unixarea(dot)de>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: SELECT in VCHAR column for strings with TAB
Date: 2021-06-10 13:50:02
Message-ID: 1558492.1623333002@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthias Apitz <guru(at)unixarea(dot)de> writes:
> I want to search in a VCHAR column for a string with two TAB at the end.
> I tried some things w/o any luck, like:

> select * from acq_vardata where name=concat('Test202112', 9, 9);
> select * from acq_vardata where name=concat('Test202112', '\t\t');

By default, backslash is not magic in SQL literals. The right way
to spell that is something like

select * from acq_vardata where name = E'Test202112\t\t';

See the discussion of "escape strings" in

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Kühtreiber 2021-06-10 16:06:00 Re: Logical Replication: SELECT pg_catalog.set_config Statement appears to be hanging
Previous Message Ray O'Donnell 2021-06-10 13:39:55 Re: SELECT in VCHAR column for strings with TAB