From: sivapostgres@yahoo.com <sivapostgres@yahoo.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: select * from test where name like 'co_%'
Date: Tue, 10 Mar 2020 13:05:20 +0000 (UTC)
Message-ID: <1984187071.3080276.1583845520147@mail.yahoo.com> (raw)
In-Reply-To: <CABNMRRwkfwz46w3_=8saYxUE39KTLhqEOGaDA5UKrjwYNqcoCQ@mail.gmail.com>
References: <1482349013.1084585.1583844541651.ref@mail.yahoo.com>
<1482349013.1084585.1583844541651@mail.yahoo.com>
<CABNMRRwkfwz46w3_=8saYxUE39KTLhqEOGaDA5UKrjwYNqcoCQ@mail.gmail.com>
Thanks. Got it.
On Tuesday, 10 March, 2020, 06:30:27 pm IST, Paul Foerster <paul.foerster@gmail.com> wrote:
Hi,
an underscore matches a single character, any character. You'd have to
escape it and tell the query what the escape character is if you want
it to be treated as a standard character:
db=# create table t(t text);
CREATE TABLE
db=# insert into t(t) values ('fox'), ('fo_'), ('fo_x');
INSERT 0 3
db=# select * from t;
t
------
fox
fo_
fo_x
(3 rows)
db=# select * from t where t like 'fo_%';
t
------
fox
fo_
fo_x
(3 rows)
db=# select * from t where t like 'fo\_%' escape '\';
t
------
fo_
fo_x
(2 rows)
Cheers,
Paul
On Tue, Mar 10, 2020 at 1:49 PM sivapostgres@yahoo.com
<sivapostgres@yahoo.com> wrote:
>
> Hello,
>
> What returns when I run a query like this;
>
> Select * from test where name like 'co_%';
>
> I expect anything that starts with 'co_' and NOT 'co' only. Am I right? But I get every names that starts with 'co'. Why ?
>
> Happiness Always
> BKR Sivaprakash
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sivapostgres@yahoo.com
Subject: Re: select * from test where name like 'co_%'
In-Reply-To: <1984187071.3080276.1583845520147@mail.yahoo.com>
References: <1482349013.1084585.1583844541651.ref@mail.yahoo.com> <1482349013.1084585.1583844541651@mail.yahoo.com> <CABNMRRwkfwz46w3_=8saYxUE39KTLhqEOGaDA5UKrjwYNqcoCQ@mail.gmail.com> <1984187071.3080276.1583845520147@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox